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
Please note: These are Amazon affiliate links. If you buy the components through these links, We will get a commission at no extra cost to you. We appreciate it.

The Best Arduino Starter Kit

※ OUR MESSAGES