HI, I got an error I just need to fix it it, can you please help me with it
below is the error:-4_pushbutton_arduino_ide_tutorial_keyboard_and_mouse:54:3: error: expected unqualified-id before 'if'
if (digitalRead(WButton) == HIGH); {
^~
4_pushbutton_arduino_ide_tutorial_keyboard_and_mouse:54:38: error: expected unqualified-id before '{' token
if (digitalRead(WButton) == HIGH); {
^
4_pushbutton_arduino_ide_tutorial_keyboard_and_mouse:57:3: error: expected unqualified-id before 'if'
if (digitalRead(SButton) == HIGH); {
^~
4_pushbutton_arduino_ide_tutorial_keyboard_and_mouse:57:38: error: expected unqualified-id before '{' token
if (digitalRead(SButton) == HIGH); {
^
4_pushbutton_arduino_ide_tutorial_keyboard_and_mouse:60:3: error: expected unqualified-id before 'if'
if (digitalRead(AButton) == HIGH); {
^~
4_pushbutton_arduino_ide_tutorial_keyboard_and_mouse:60:38: error: expected unqualified-id before '{' token
if (digitalRead(AButton) == HIGH); {
^
4_pushbutton_arduino_ide_tutorial_keyboard_and_mouse:63:3: error: expected unqualified-id before 'if'
if (digitalRead(DButton) == HIGH); {
^~
4_pushbutton_arduino_ide_tutorial_keyboard_and_mouse:63:38: error: expected unqualified-id before '{' token
if (digitalRead(DButton) == HIGH); {
^
Using library Keyboard at version 1.0.2 in folder: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.33.0_x86__mdqgnx93n4wtt\libraries\Keyboard
Using library HID at version 1.0 in folder: C:\Program Files\WindowsApps\ArduinoLLC.ArduinoIDE_1.8.33.0_x86__mdqgnx93n4wtt\hardware\arduino\avr\libraries\HID
exit status 1
expected unqualified-id before 'if'
and below is the code:-
#include <Keyboard.h>
// set pin numbers for the five buttons:
const int WButton = 2;
const int SButton = 3;
const int AButton = 4;
const int DButton = 5;
void setup() { // initialize the buttons' inputs:
pinMode(WButton, INPUT);
pinMode(SButton, INPUT);
pinMode(AButton, INPUT);
pinMode(DButton, INPUT);
Serial.begin(9600);
// initialize mouse control:
Keyboard.begin();
}
void loop() {
// use serial input to control the mouse:
if (Serial.available() > 0) <<< needs a { here
char inChar = Serial.read();}
// use the pushbuttons to control the keyboard:
if (digitalRead(WButton) == HIGH); {
Keyboard.write('W');
}
if (digitalRead(SButton) == HIGH); {
Keyboard.write('S');
}
if (digitalRead(AButton) == HIGH); {
Keyboard.write('A');
}
if (digitalRead(DButton) == HIGH); {
Keyboard.write('D');
}
} and this one was missing here
Don't forget CTRL-T to format the code better, lines up ( ), { }, etc for you.
[/code]