Hello, I need a little bit of help. I want to make a main menu on lcd display, and I want to connect 3 button, Button1: left Button2: Ok Button3: right
I only have free pin in Analog side, so I connected the 3 buttons to A0 A1 and A2.
I already figoured it out that I have to set the PC0 PC1 and PC0 pin to Input.
DDRC&=0b11111000; like this. But i dont know what to write in the Loop().
Can somebody help me?
Are you asking for help writing to the LCD or are you asking for help with the Keypad.
The keypad is set in a matrix fashion of Rows and columns. So R1 and C1 is key 1 etc.
note that either the rows or the columns have to be an Input and the other an output for the system to work like a wire. Its incredibly simple.
The LCD is another matter as I have not messed around with these yet.
void setup() {
// put your setup code here, to run once:
DDRC &= 0b11111000;
PORTC |= 0b00000111; // A0-A2 as PullUp
// pinMode(A0, INPUT_PULLUP);
}
void loop() {
// put your main code here, to run repeatedly:
if((PINC & 0b00000001) == 0) { // Test bit 0 only
PORTB |= 0b00100000; // BUILTIN_LED pin 13 On
} else {
PORTB &= ~0b00100000; // BUILTIN_LED pin 13 Off
}
/* or this way
if(PINC & 0b00000001) { // Test bit 0 only
PORTB &= ~0b00100000; // BUILTIN_LED pin 13 Off
} else {
PORTB |= 0b00100000; // BUILTIN_LED pin 13 On
}
*/
}