Advertisement
Guest User

Untitled

a guest
Mar 19th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. #include <Wire.h>
  2. #include <LCD.h>
  3. #include <LiquidCrystal_I2C.h>
  4. LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
  5. int getal = 0;
  6. int getalUIT = 0;
  7. int knopStatus = 0;
  8. const int knopPin = 2;
  9.  
  10. void setup() {
  11. pinMode(knopPin, INPUT);
  12. lcd.begin(16,2);
  13. lcd.setCursor(2, 0);
  14. lcd.print("Fietsen naar");
  15. lcd.setCursor(4, 1);
  16. lcd.print("Burrundi!");
  17. delay(100);
  18. }
  19.  
  20. void loop() {
  21. knopStatus = digitalRead(knopPin);
  22.  
  23. if (knopStatus == HIGH) {
  24. getal=getal+10;
  25. }
  26. if (getal == 0) {
  27.  
  28. } else if (getal >= 1000) {
  29. if(getal >= 1000 && getal < 1100) {
  30. lcd.clear();
  31. lcd.setCursor(3,0);
  32. lcd.print("Er is ");
  33. lcd.print(getal/1000);
  34. lcd.print(",0");
  35. lcd.print((getal%1000)/10);
  36. lcd.setCursor(13, 0);
  37. lcd.print("km");
  38. lcd.setCursor(3,1);
  39. lcd.print("afgelegd!");
  40. } else {
  41. lcd.clear();
  42. lcd.setCursor(3,0);
  43. lcd.print("Er is ");
  44. lcd.print(getal/1000);
  45. lcd.print(",");
  46. lcd.print((getal%1000)/10);
  47. lcd.setCursor(13, 0);
  48. lcd.print("km");
  49. lcd.setCursor(3,1);
  50. lcd.print("afgelegd!");
  51. }
  52.  
  53. } else {
  54. lcd.clear();
  55. lcd.setCursor(3,0);
  56. lcd.print("Er is ");
  57. lcd.print(getal);
  58. lcd.setCursor(13, 0);
  59. lcd.print("m");
  60. lcd.setCursor(3,1);
  61. lcd.print("afgelegd!");
  62. }
  63. delay(150);
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement