#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int cursor=7;
const int l=10, d=9, u=8, r=7;
byte customChar[] = {
B01110,
B01110,
B00100,
B11111,
B10101,
B00100,
B01010,
B11011
};
byte customCharright[] = {
B00111,
B00111,
B00100,
B00111,
B00110,
B00101,
B01010,
B01001
};
byte customCharleft[] = {
B11100,
B11100,
B00100,
B11100,
B01100,
B10100,
B01010,
B10010
};
byte customCharup[] = {
B01110,
B01110,
B10101,
B01110,
B00100,
B00100,
B01010,
B11011
};
byte left[] = {
B00100,
B00010,
B00001,
B11111,
B11111,
B00001,
B00010,
B00100
};
byte right[] = {
B00100,
B01000,
B10000,
B11111,
B11111,
B10000,
B01000,
B00100
};
void setup() {
lcd.begin(16, 2);
pinMode(l, INPUT);
pinMode(r, INPUT);
pinMode(u, INPUT);
pinMode(d, INPUT);
lcd.createChar(0, customChar);
lcd.createChar(1, left);
lcd.createChar(2, right);
lcd.createChar(3, customCharright);
lcd.createChar(4, customCharleft);
lcd.createChar(5, customCharup);
lcd.home();
lcd.print("Mechatron");
lcd.setCursor(8,1);
lcd.print("Robotics");
delay(2000);
for(int i=0; i<16; i++)
{
lcd.clear();
lcd.setCursor(i,0);
lcd.write(byte(1));
delay(50);
}
for(int i=16; i>=0; i--)
{
lcd.clear();
lcd.setCursor(i,1);
lcd.write(byte(2));
delay(50);
}
lcd.clear();
}
void loop() {
//lcd.clear();
lcd.setCursor(cursor,0);
lcd.write(byte(0));
lcd.setCursor(4,1);
lcd.print("Move Me");
delay(20);
if(digitalRead(r) == HIGH)
{
if (cursor>=0 && cursor<16)
{
cursor++;
lcd.clear();
lcd.setCursor(cursor,0);
lcd.write(byte(3));
delay(200);
}
}
if(digitalRead(l) == HIGH)
{
if (cursor>=0 && cursor<16)
{
cursor--;
lcd.clear();
lcd.setCursor(cursor,0);
lcd.write(byte(4));
delay(200);
}
}
if(digitalRead(u) == HIGH)
{
if (cursor>=0 && cursor<16)
{
lcd.clear();
lcd.setCursor(cursor,0);
lcd.write(byte(5));
delay(200);
}
}
if(digitalRead(d) == HIGH)
{
lcd.clear();
lcd.setCursor(cursor,1);
lcd.write(byte(0));
delay(200);
}
}
Comments
Please log in or sign up to comment.