error: expected ',' or ';' before
Arduino IDE shows an error:
C:\Users\Documents\Arduino\Code\Code.ino: In function 'void setup()':
draft:4:3: error: expected ',' or ';' before 'Serial'
Serial.println(myVal);
^~~~~~
exit status 1
expected ',' or ';' before 'Serial'
My code is:
void setup() {
Serial.begin(9600);
int myVal = 5
Serial.println(myVal);
}
void loop() {
// put your main code here, to run repeatedly:
}
How can I solve it?
Answer
This is a common mistake for beginners who just got started to learn programming.
It is very easy to solve. You just need to put a comma before that line
void setup() {
Serial.begin(9600);
int myVal = 5; // comma here
Serial.println(myVal);
}
void loop() {
// put your main code here, to run repeatedly:
}
Buy Arduino
1 × Arduino UNO Buy on Amazon | |
1 × USB 2.0 cable type A/B Buy on Amazon | |
1 × Jumper Wires Buy on Amazon |
Disclosure: Some links in this section are Amazon affiliate links. If you make a purchase through these links, we may earn a commission at no extra cost to you.
Additionally, some links direct to products from our own brand, DIYables.
Additionally, some links direct to products from our own brand, DIYables.