Devices & Components
Arduino Uno Rev3
Alphanumeric LCD, 16 x 2
Tactile Switch, Top Actuated
Project description
Code
Animation Studios
arduino
This is the code of our creation
1#include <LiquidCrystal.h> 2 3LiquidCrystal lcd(12, 11, 5, 4, 3, 2); 4 5int cursor=7; 6const int l=10, d=9, u=8, r=7; 7 8byte customChar[] = { 9 10 B01110, 11 B01110, 12 B00100, 13 B11111, 14 B10101, 15 B00100, 16 B01010, 17 18 B11011 19}; 20byte customCharright[] = { 21 B00111, 22 B00111, 23 B00100, 24 25 B00111, 26 B00110, 27 B00101, 28 B01010, 29 B01001 30}; 31byte customCharleft[] 32 = { 33 B11100, 34 B11100, 35 B00100, 36 B11100, 37 B01100, 38 B10100, 39 40 B01010, 41 B10010 42}; 43byte customCharup[] = { 44 B01110, 45 B01110, 46 47 B10101, 48 B01110, 49 B00100, 50 B00100, 51 B01010, 52 B11011 53}; 54byte 55 left[] = { 56 B00100, 57 B00010, 58 B00001, 59 B11111, 60 B11111, 61 62 B00001, 63 B00010, 64 B00100 65}; 66byte right[] = { 67 B00100, 68 B01000, 69 70 B10000, 71 B11111, 72 B11111, 73 B10000, 74 B01000, 75 B00100 76}; 77 78void 79 setup() { 80 lcd.begin(16, 2); 81 pinMode(l, INPUT); 82 pinMode(r, INPUT); 83 84 pinMode(u, INPUT); 85 pinMode(d, INPUT); 86 lcd.createChar(0, customChar); 87 88 lcd.createChar(1, left); 89 lcd.createChar(2, right); 90 lcd.createChar(3, 91 customCharright); 92 lcd.createChar(4, customCharleft); 93 lcd.createChar(5, 94 customCharup); 95 lcd.home(); 96 lcd.print("Mechatron"); 97 lcd.setCursor(8,1); 98 99 lcd.print("Robotics"); 100 delay(2000); 101 for(int i=0; i<16; i++) 102 { 103 104 lcd.clear(); 105 lcd.setCursor(i,0); 106 lcd.write(byte(1)); 107 delay(50); 108 109 } 110 for(int i=16; i>=0; i--) 111 { 112 lcd.clear(); 113 lcd.setCursor(i,1); 114 115 lcd.write(byte(2)); 116 delay(50); 117 } 118 lcd.clear(); 119} 120 121void 122 loop() { 123 //lcd.clear(); 124 lcd.setCursor(cursor,0); 125 lcd.write(byte(0)); 126 127 lcd.setCursor(4,1); 128 lcd.print("Move Me"); 129 delay(20); 130 if(digitalRead(r) 131 == HIGH) 132 { 133 if (cursor>=0 && cursor<16) 134 { 135 cursor++; 136 137 lcd.clear(); 138 lcd.setCursor(cursor,0); 139 lcd.write(byte(3)); 140 141 delay(200); 142 } 143 } 144 145 if(digitalRead(l) == HIGH) 146 { 147 148 if (cursor>=0 && cursor<16) 149 { 150 cursor--; 151 lcd.clear(); 152 153 lcd.setCursor(cursor,0); 154 lcd.write(byte(4)); 155 delay(200); 156 157 } 158 } 159 if(digitalRead(u) == HIGH) 160 { 161 if (cursor>=0 && cursor<16) 162 163 { 164 lcd.clear(); 165 lcd.setCursor(cursor,0); 166 lcd.write(byte(5)); 167 168 delay(200); 169 } 170 } 171 if(digitalRead(d) == HIGH) 172 { 173 lcd.clear(); 174 175 lcd.setCursor(cursor,1); 176 lcd.write(byte(0)); 177 delay(200); 178 179 180 } 181}
Downloadable files
Animation Studios
This is the the schematic of our circuit. With all the hardware components included.
Animation Studios

Animation Studios
This is the the schematic of our circuit. With all the hardware components included.
Animation Studios

Comments
Only logged in users can leave comments