Devices & Components
Arduino Uno Rev3
Breadboard (generic)
USB-A to B Cable
Rotary potentiometer (generic)
Pushbutton
Alphanumeric LCD, 16 x 2
Jumper wires (generic)
Software & Tools
Arduino IDE
Project description
Code
Reee machine
arduino
1// ree machine 2 3 4#include <LiquidCrystal.h> 5 6const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2; 7LiquidCrystal lcd(rs, en, d4, d5, d6, d7); 8 9const int reeDelay = 50; 10 11int n = 0; 12int c = 1; 13int state = 0; 14int welcome = 0; 15int button; 16 17 18byte customChar[] = { //bold E 19 B11111, 20 B11111, 21 B11000, 22 B11111, 23 B11111, 24 B11000, 25 B11111, 26 B11111 27}; 28 29byte customChar2[] = { //bold R 30 B11110, 31 B11011, 32 B11011, 33 B11110, 34 B11100, 35 B11110, 36 B11011, 37 B11001 38}; 39 40 41void setup() { 42 43 Serial.begin(9600); 44 lcd.begin(16, 2); 45 lcd.print("----------------"); 46 lcd.display(); 47 delay(500); 48 lcd.clear(); 49 lcd.createChar(1, customChar); 50 lcd.createChar(2, customChar2); 51 lcd.home(); 52} 53 54void loop() { 55 button = analogRead(A0); 56 Serial.print(button); 57 Serial.print("\ 58"); 59 Serial.print(state); 60 Serial.print("\ 61"); 62 63 if (button > 1020 && state == 0){ 64 lcd.clear(); 65 state = 1; 66 welcome = 0; 67 delay(1000); 68 } 69 else if (state == 1 && button <= 1020){ 70 Serial.print("elseif1 "); 71 ree(); 72 } 73 else if (state == 1 && button > 1020){ 74 Serial.print("elseif2"); 75 state = 0; 76 n = 0; 77 c = 1; 78 lcd.clear(); 79 delay(1000); 80 } 81 else if (state == 0 && button <= 1020 && welcome == 0){ 82 Serial.print("elseif3"); 83 lcd.write("->PRESS TO REE<-"); 84 lcd.setCursor(0, 1); 85 lcd.write("ree machine v2.0"); 86 welcome = 1; 87 } 88} 89 90 91 92 93void ree() { 94 Serial.print("ree on "); 95 96 if (n==0 && c==1){ 97 lcd.write(2); 98 n= n + 1; 99 } 100 101 if (n < 16){ 102 lcd.write(1); 103 n= n + 1; 104 } 105 106 else if (n == 16 && c == 1){ 107 c=2; 108 n=0; 109 lcd.setCursor(0,1); 110 } 111 112 else if (c==2 && n==16){ 113 delay(200); 114 lcd.clear(); 115 c=1; 116 n=0; 117 delay(500); 118 } 119 120 delay(reeDelay); 121} 122
Downloadable files
ree machine
just press the button
ree machine

ree machine
just press the button
ree machine

Comments
Only logged in users can leave comments