Hi,
I'm very new to C++ and I'm trying to make a bluetooth app that allows me to turn on and off two light with an app. There are two lights connected to two different pins that I want to turn on when the arduino receives a "2" and turns off when it receives a "3". I'm using an arduino Nano BLE.
When I run the code I've written, it comes up with the error:
"expected ')' before ';' token" on line 18 (where it says "Recieved = Serial.read();" within the void loop)
I've had a look at some tutorials but I haven't found a solution yet.
Thanks for any help!
int light_1 = 2;
int light_2 = 3;
//variables
int Recieved = 0;
int light_1_state = 0;
int light_2_state = 0;
void setup() {
Serial.begin(9600);
pinMode(light_1, OUTPUT);
pinMode(light_2, OUTPUT);
}
void loop() {
if (Serial.available() > 0)
(
Recieved = Serial.read();
)
/////////Light/////////////
if (light_1_state == 0 && Recieved == '2')
(
digitalWrite(light_1, HIGH);
digitalWrite(light_2, HIGH);
Recieved = 0;
light_1_state = 1;
)
if (light_1_state == 1 && Recieved == '3')
(
digitalWrite(light_1, LOW);
digitalWrite(light_2, LOW);
Recieved = 0;
light_1_state = 0;
)
}