i have been trying to fix this for a whole hour and i couldnt . im a begginer and im trying to make a keyboard using arduino that can write a and b
// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
Serial.begin(9600);
pinMode(10,INPUT);
pinMode(9,INPUT);
}
void loop() {
if(digitalRead(10)==HIGH){
lcd.print("a");
}else(){if(digitalRead(9)==HIGH){
lcd.print("b");
}else(){
lcd.clear();}
delay(1000);
}}
the error is here }else(){if(digitalRead(9)==HIGH){
i think its one of the pre-made command for c++ that if the answer wasnt true then it will run another if command . i i did it for if the a key didnt get pressed it checks if b key is pressed
It is personal choice but I find that putting each { and } on its own line and always using them with conditional statements makes the code block for each condition much clearer, particularly when the conditions are nested