I keep getting these errors and i follow through and i gives me this and the edits it tells me to make aren't supposed to be in my code could some one3 tell me what i could have did wrong? Thanks.
NIGHTLIGHT:84:2: error: expected primary-expression before 'if'
(if else
^~
NIGHTLIGHT:84:2: error: expected ')' before 'if'
exit status 1
---------------------------------ERROR MESSAGES----------------------------------------------------------
Arduino: 1.8.12 (Mac OS X), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"
NIGHTLIGHT:41:2: error: expected primary-expression before 'if'
(if else (ledMode == 2);
^~
NIGHTLIGHT:41:2: error: expected ')' before 'if'
NIGHTLIGHT:48:2: error: expected primary-expression before 'if'
(if else (ledMode == 3);
^~
NIGHTLIGHT:48:2: error: expected ')' before 'if'
NIGHTLIGHT:55:4: error: expected '(' before 'else'
if else (ledMode == 4);
^~~~
NIGHTLIGHT:62:2: error: expected primary-expression before 'if'
(if else (ledMode == 5);
^~
NIGHTLIGHT:62:2: error: expected ')' before 'if'
NIGHTLIGHT:69:2: error: expected primary-expression before 'if'
(if else (ledMode == 6);
^~
NIGHTLIGHT:69:2: error: expected ')' before 'if'
NIGHTLIGHT:77:2: error: expected primary-expression before 'if'
(if else (ledMode == 7);
^~
NIGHTLIGHT:77:2: error: expected ')' before 'if'
NIGHTLIGHT:84:2: error: expected primary-expression before 'if'
(if else
^~
NIGHTLIGHT:84:2: error: expected ')' before 'if'
exit status 1
expected primary-expression before 'if'
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
CODE:
const int BLED = 9;
const int GLED = 10;
const int RLED = 11;
const int BUTTON = 2;
boolean currentButton = LOW;
int ledMode = 0;
void setup()
{
pinMode (BLED, OUTPUT);
pinMode (GLED, OUTPUT);
pinMode (RLED, OUTPUT);
pinMode (BUTTON, INPUT);
}
void loop()
{
currentButton = digitalRead (BUTTON);
if (currentButton == HIGH)
{
ledMode++;
}
if (ledMode >= 8);
{
ledMode = 0;
}
setMode();
}
void setMode()
{
if (ledMode == 1);
{
analogWrite (BLED, 255);
analogWrite (GLED, 0);
analogWrite (RLED, 0);
}
// Blue Light
(if else (ledMode == 2);
{
analogWrite (BLED, 0);
analogWrite (GLED, 255);
analogWrite (RLED, 0);
}
// Green Light
(if else (ledMode == 3);
{
analogWrite (BLED, 0);
analogWrite (GLED, 0);
analogWrite (RLED, 255);
}
// Purple Light
if else (ledMode == 4);
{
analogWrite (BLED, 127);
analogWrite (GLED, 0);
analogWrite (RLED, 127);
}
//Teal Light
(if else (ledMode == 5);
{
analogWrite (BLED, 0);
analogWrite (GLED, 127);
analogWrite (RLED, 127);
}
// Orange Light
(if else (ledMode == 6);
{
analogWrite (BLED, 127);
analogWrite (GLED, 127);
analogWrite (RLED, 0);
}
// white Light
(if else (ledMode == 7);
{
analogWrite (BLED, 85);
analogWrite (GLED, 85);
analogWrite (RLED, 85);
}
// Off (ledMode == 7);
(if else
{
digitalWrite (BLED, LOW);
digitalWrite (GLED, LOW);
digitalWrite (RLED, LOW);
}
}