Hello everybode
I'm trying to use a button as a start switch but it doesn't work when i upload it.
What happens : when i launch it to the arduino it right away the display (16x2) starts, but when i press the button it doesn't do anything
here's the code
/*
pin VSS = pin GND
pin VDD = pin +5V
pin V0 = pin middle potentiometer (10KΩ)
pin RS = pin 12
pin RW = pin 11
pin E = pin GND
pin D4 = pin 5
pin D5 = pin 4
pin D6 = pin 3
pin D7 = pin 2
pin A (150Ω) = pin +5V
pin K = pin GND
Left pin potentiometer = pin +5V
Right pin potentiometer = pin GND
*/
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int a = 22;
byte swingLeft2[8] = {
0b00000,
0b00000,
0b10000,
0b11000,
0b01100,
0b00110,
0b00011,
0b00001
};
byte body[8] = {
0b00000,
0b01110,
0b11111,
0b11111,
0b01110,
0b00100,
0b11111,
0b11111
};
byte swingRight2[8] = {
0b00000,
0b00000,
0b00001,
0b00011,
0b00110,
0b01100,
0b11000,
0b10000
};
byte swingLeft3[8] = {
0b00011,
0b00011,
0b00011,
0b00011,
0b00011,
0b00011,
0b00011,
0b00001
};
byte swingLeft1[8] = {
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b11111,
0b11111
};
byte swingRight1[8] = {
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b11111,
0b11111
};
byte swingRight3[8] = {
0b11000,
0b11000,
0b11000,
0b11000,
0b11000,
0b11000,
0b11000,
0b10000
};
void setup() {
pinMode(22,INPUT);
lcd.begin(16, 2);
lcd.createChar(6, body);
lcd.createChar(5, swingLeft2);
lcd.createChar(8, swingLeft3);
lcd.createChar(9, swingLeft1);
lcd.createChar(7, swingRight2);
lcd.createChar(10, swingRight1);
lcd.createChar(11, swingRight3);
}
void loop()
{
a=digitalRead(22);
if(a==0)
{
back :
lcd.setCursor(3, 0);
lcd.write("Matthias H");
lcd.setCursor(6, 1);
lcd.write(9);
lcd.write(6);
lcd.write(10);
delay(500);
lcd.setCursor(6, 1);
lcd.write(5);
lcd.write(6);
lcd.write(7);
delay(500);
lcd.setCursor(6, 1);
lcd.write(8);
lcd.write(6);
lcd.write(11);
delay(500);
lcd.setCursor(6, 1);
lcd.write(5);
lcd.write(6);
lcd.write(7);
delay(500);
goto back;
}
else
{
lcd.clear();
}
}
Thx
LCD_MEN.txt (4.29 KB)