Why does this program show 'else without a previous if?'
//OPEN ROAD
//This program was designed by x for the Open Road project
int Vibration1 = 8; // Sets the vibration motor's power source to pin 8
int Vibration2 = 12; // Sets the second vibration motor's power source to pin 12
int BuzzerPower = 7; // Sets the positive voltage to the buzzer at pin 7.
int BuzzerSignal = 13; // Sets the signal to the buzzer at pin 13.
int message = 0; // Sets the port at which the Arduino will receive information from the phone to 0 (RX) and defines the information under the variable 'message'.
void setup() {
pinMode(BuzzerPower, OUTPUT); // Sets the voltage of the buzzer to an output, which makes the Arduino expect to send energy there rather than receive it
pinMode(BuzzerSignal,OUTPUT); // Sets the signal to the buzzer to an output, which makes the Arduino expect to send a signal there rather than receive one
digitalWrite(BuzzerPower,HIGH); // Sets the power to the buzzer at High.
Serial.begin(38400); // Sets the communication with the Bluetooth module
}
void loop() {
if(Serial.available() > 0) // If more than 0 bytes of data are being received
message = Serial.read(); // The variable 'state;
{
if (message == 1); // If the phone sends a message to turn on the alarm
{
digitalWrite(BuzzerSignal, HIGH); // Set the buzzer to loud
digitalWrite(Vibration1,HIGH); // Set Motor 1 to high
digitalWrite(Vibration2,HIGH); // Set Motor 2 to high
delay(1000); //
digitalWrite(BuzzerSignal, HIGH); // Set the buzzer to loud
digitalWrite(Vibration1,HIGH); // Set Motor 1 to high
digitalWrite(Vibration2,HIGH); // Set Motor 2 to high
delay(1000);
digitalWrite(BuzzerSignal, HIGH); // Set the buzzer to loud
digitalWrite(Vibration1,HIGH); // Set Motor 1 to high
digitalWrite(Vibration2,HIGH); // Set Motor 2 to high
delay(1000);
digitalWrite(BuzzerSignal, LOW); // Set the buzzer to off
digitalWrite(Vibration1,LOW); // Set Motor 1 to off
digitalWrite(Vibration2,LOW); // Set Motor 2 to off
}
else if (message == 2) // If the phone sends a message to calibrate
{
dd
}
else;
{
digitalWrite(BuzzerSignal, LOW); // Set the buzzer to off
digitalWrite(Vibration1,LOW); // Set Motor 1 to off
digitalWrite(Vibration2,LOW); // Set Motor 2 to off
}
}
}