Advertisement
krshr

Arduino4

Feb 1st, 2019
2,888
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <LiquidCrystal.h> //
  2. LiquidCrystal lcd( 4, 5, 6, 7,8 ,9 );
  3. float input_volt = 0.0;
  4. float temp=0.0;
  5. float r1=10000.0; //r1 valor
  6. float r2=100000.0; //r2 valor
  7.  
  8. void setup()
  9. {
  10. Serial.begin(9600); //
  11. lcd.begin(16, 2); ////
  12. lcd.print("DC DIGI VOLTMETRO");
  13. }
  14.  
  15. void loop()
  16. {
  17. int analogvalue = analogRead(A0);
  18. temp = (analogvalue * 5.0) / 1024.0; //
  19. input_volt = temp / (r2/(r1+r2));
  20. if (input_volt < 0.1)
  21. {
  22. input_volt=0.0;
  23. }
  24. Serial.print("v= "); //
  25. Serial.println(input_volt);
  26. lcd.setCursor(0, 1);
  27. lcd.print("Voltage= "); //
  28. lcd.print(input_volt);
  29. delay(300);
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement