Last active
July 21, 2017 22:22
-
-
Save AsaK/91e27f3bc64c9aba63e903d66d48a7ad to your computer and use it in GitHub Desktop.
Verificar três sensores de temperatura LM35 - ARDUINO
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
| // Define Constante da porta ANALOGICA 0 para o Sensor 1 | |
| const int LM35_1 = A0; | |
| // Define Constante da porta ANALOGICA 1 para o Sensor 2 | |
| const int LM35_2 = A1; | |
| // Define Constante da porta ANALOGICA 2 para o Sensor 3 | |
| const int LM35_3 = A2; | |
| // Variaveis | |
| float temperatura_1; | |
| float temperatura_2; | |
| float temperatura_3; | |
| float media_temperatura; | |
| void setup() { | |
| //Inicia a porta Serial para comunicação | |
| Serial.begin(9600); | |
| } | |
| void loop() { | |
| // Ler a temperatura do Sensor 1 | |
| temperatura_1 = (float(analogRead(LM35_1))*5/(1023))/0.01; | |
| // Ler a temperatura do Sensor 2 | |
| temperatura_2 = (float(analogRead(LM35_2))*5/(1023))/0.01; | |
| // Ler a temperatura do Sensor 3 | |
| temperatura_3 = (float(analogRead(LM35_3))*5/(1023))/0.01; | |
| // Imprime a temperatura do Sensor 1 | |
| Serial.print("Sensor 1: "); | |
| Serial.print(temperatura_1); | |
| Serial.print("C"); | |
| // Imprime a temperatura do Sensor 2 | |
| Serial.print("Sensor 2: "); | |
| Serial.print(temperatura_2); | |
| Serial.print("C"); | |
| // Imprime a temperatura do Sensor 3 | |
| Serial.print("Sensor 3: "); | |
| Serial.print(temperatura_3); | |
| Serial.print("C"); | |
| media_temperatura = ((temperatura_1 + temperatura_2 + temperatura 3) / 3); | |
| Serial.print("Media: "); | |
| Serial.print(media_temperatura); | |
| Serial.print("C"); | |
| delay(1000); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment