You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.2 KiB

4 years ago
  1. #include "Nokia_5110.h"
  2. //https://github.com/baghayi/Nokia_5110
  3. //MIT license
  4. //These have been slightly edited from default (normal is 2,3,4,5,6)
  5. #define RST 3
  6. #define CE 4
  7. #define DC 5
  8. #define DIN 6
  9. #define CLK 7
  10. Nokia_5110 lcd = Nokia_5110(RST, CE, DC, DIN, CLK);
  11. #define PHSENSOR A3
  12. //uno is 10 bit adc
  13. uint16_t phVal_u16 = 0;
  14. float phFloat = 0;
  15. void setup() {
  16. Serial.begin(9600);
  17. /**
  18. * Note: if instead of text being shown on the display, all the segments are on, you may need to decrease contrast value.
  19. */
  20. lcd.setContrast(28); // 60 is the default value set by the driver
  21. //lcd.print("Please Wait ...");
  22. lcd.setCursor(15,1);
  23. lcd.print("Starting...");
  24. delay(800);
  25. lcd.clear();
  26. //lcd.print("Hi there");
  27. //lcd.println(":D");
  28. //lcd.setCursor(0, 5);
  29. //lcd.println("1 2 3 ...");
  30. }
  31. void loop() {
  32. lcd.clear();
  33. phVal_u16 = analogRead(PHSENSOR);
  34. phFloat = phVal_u16 * 0.013672;
  35. lcd.setCursor(15,1);
  36. lcd.println("Raw:");
  37. lcd.setCursor(45,2);
  38. lcd.print(phVal_u16);
  39. lcd.setCursor(15,3);
  40. lcd.println("PH #:");
  41. lcd.setCursor(45,4);
  42. lcd.print(phFloat);
  43. //Serial.println(phVal_u16);
  44. delay(1000);
  45. }