Advertisement
Guest User

Untitled

a guest
Mar 19th, 2018
506
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #include <LiquidCrystal.h>
  2.  
  3. LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
  4. unsigned long time;
  5.  
  6. void setup() {
  7. Serial.begin(9600);
  8.  
  9. }
  10.  
  11. void loop() {
  12. //lcd.setCursor(0, 1);
  13. //lcd.print(millis()/1000);
  14. // read the input on analog pin 0:
  15. int sensorValue = analogRead(A0);
  16. // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
  17. float voltage = sensorValue * (5.0 / 1023.0);
  18. // print out the value you read:
  19. Serial.println(voltage);
  20. lcd.begin(16, 2);
  21. lcd.print("Voltage: ");
  22. lcd.print(voltage);
  23.  
  24. lcd.setCursor(14,1);
  25. lcd.print("YP");
  26.  
  27. lcd.setCursor(0,1);
  28. lcd.print("Time: ");
  29. lcd.setCursor(5,1);
  30. time = millis();
  31. //Serial.println(time/1000);
  32. lcd.println(time/1000); //prints time since program started
  33. delay(50); // wait a second so as not to send massive amounts of data- stops overload of lcd screen
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement