I am doing a communication, serial in the simulator tinkercad, between two arduino, my code is presented, error:
else without a predictive if
The idea of programming is to press button, in the arduino emitter is to light led in the emitter and second led, in the other arduino, receiver by serial communication ..
Arduino emitter
void setup() {
Serial.begin(9600);
pinMode(11,INPUT);
pinMode(10,OUTPUT);
}
void loop() {
if(digitalRead(11)){
digitalWrite(10,1);
Serial.println(255);
}
else{
digitalWrite(10,0);
Serial.println(0);
}
delay(100);
}
Arduino receiver
void setup() {
Serial.begin(9600);
pinMode(8,INPUT);
pinMode(10,OUTPUT);
int value;
}
void loop() {
while (Serial.available() > 0) {
int value = Serial.parseInt();
Serial.println(value);
if ( value == 255);{
digitalWrite(10,1);
}else {
digitalWrite(10,0);
}
}
}