Created
May 30, 2023 16:06
-
-
Save Rumidom/4e833985f9b688e6afc3a5d4a7cbfc71 to your computer and use it in GitHub Desktop.
Placa de testes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <OneWire.h> | |
| #include <DallasTemperature.h> | |
| int LED1_PIN = 2; | |
| int LED2_PIN = 12; | |
| int LED3_PIN = 13; | |
| int BUZZER_PIN = 15; | |
| int BUTTON_PIN = 5; | |
| int SENSOR_PIN = 14; | |
| // Setup a oneWire instance to communicate with any OneWire devices, Cria o objeto OneWire | |
| OneWire oneWire(SENSOR_PIN); | |
| // Pass our oneWire reference to Dallas Temperature sensor DS18B20, Cria o objeto sensors | |
| DallasTemperature sensors(&oneWire); | |
| // the setup function runs once when you press reset or power the board | |
| void setup() { | |
| // Start serial communication for debugging purposes | |
| Serial.begin(9600); | |
| // Start up the library | |
| sensors.begin(); | |
| // initialize digital pin LED_BUILTIN as an output. | |
| pinMode(LED1_PIN, OUTPUT); | |
| pinMode(LED2_PIN, OUTPUT); | |
| pinMode(LED3_PIN, OUTPUT); | |
| pinMode(BUZZER_PIN, OUTPUT); | |
| pinMode(BUTTON_PIN, INPUT); | |
| // Começa Com todos os LEDs apagados | |
| digitalWrite(LED1_PIN, HIGH); | |
| digitalWrite(LED3_PIN, LOW); | |
| digitalWrite(LED2_PIN, LOW); | |
| // e o buzzer desligado | |
| digitalWrite(BUZZER_PIN, LOW); | |
| } | |
| // the loop function runs over and over again forever | |
| void loop() { | |
| digitalWrite(LED2_PIN, HIGH); // turn the LED on (HIGH is the voltage level) | |
| delay(1000); // wait for a second | |
| digitalWrite(LED2_PIN, LOW); // turn the LED off by making the voltage LOW | |
| delay(1000); // wait for a second | |
| digitalWrite(LED3_PIN, HIGH); // turn the LED on (HIGH is the voltage level) | |
| delay(1000); // wait for a second | |
| digitalWrite(LED3_PIN, LOW); // turn the LED off by making the voltage LOW | |
| delay(1000); // wait for a second | |
| digitalWrite(LED1_PIN, LOW); // Porem o LED1 é invertido LOW acende e HIGH apaga | |
| delay(1000); // wait for a second | |
| digitalWrite(LED1_PIN, HIGH); | |
| delay(1000); // wait for a second | |
| if (digitalRead(BUTTON_PIN) == HIGH){ | |
| digitalWrite(BUZZER_PIN, HIGH); // Faz Barulho quando o o codigo chega aqui e o botão está pressionado | |
| } | |
| delay(1000); | |
| digitalWrite(BUZZER_PIN, LOW); | |
| sensors.requestTemperatures(); | |
| Serial.print("Celsius temperature (time: "); | |
| Serial.print(millis()/1000); | |
| Serial.print(" s): "); | |
| Serial.print(sensors.getTempCByIndex(0)); | |
| Serial.println("c"); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment