Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <LiquidCrystal595.h>
- LiquidCrystal595 lcd (2,3,4);
- int Temp, valor, LM35; // Variaveis para LM35 - Temperatura, gravar valor e porta A0 LM35
- int Pot = A2, ValorPot = 0, ValorBinario = 0; // Variaveis para o potenciometro
- byte led = 9;
- unsigned long Tempo, Tempo2; // Controle de tempo
- void setup(){
- lcd.begin (16,2);
- pinMode (led, OUTPUT); // Define led como saida
- }
- void loop(){
- if ((millis() - Tempo) > 3000){
- sensor();
- Tempo = millis();
- }
- if ((millis() - Tempo2) > 50){
- Potenciometro();
- Tempo2 = millis();
- }
- }
- void sensor(){
- valor = analogRead(LM35);
- Temp= ( 5 * valor * 100) / 1024;
- lcd.setCursor (0,0);
- lcd.print ("Sensor: ");
- lcd.print(Temp) ;
- lcd.print((char)223); // Ponto de graus
- lcd.print ("C");
- }
- void Potenciometro(){
- valor = analogRead(LM35);
- Temp= ( 5 * valor * 100) / 1024;
- ValorPot = analogRead (Pot);
- ValorBinario = map(ValorPot, 0, 1023, 0 , 41);
- lcd.setCursor (0,1);
- lcd.print ("Pot: ");
- lcd.print (ValorBinario); // imprime o valor do pot de 0 a 40
- if (valor > ValorPot){
- digitalWrite (led, HIGH);
- }
- else {
- digitalWrite (led, LOW);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement