bluetooth relays, error compiling!!
so.. sketch trying use switch relay on or off bluetooth via ardudroid keep getting error compiling
expected } @ end of input
now because incredibly tired cant see it.
anyone shed light?
thanks!!
heres sketch
char val; // variable receive data serial port
int ledpin = 2; // led connected pin 2 (on-board led)
void setup()
{
pinmode(ledpin = 2, output); // pin 2 (on-board led) output
pinmode(ledpin = 3, output); // pin 3 (on-board led) output
serial.begin(9600); // start serial communication @ 115200bps
}
void loop()
{
if ( serial.available() ) // if data available read
{
;
}
val = serial.read(); // read , store in 'val'
if ( val == 'a' ) // if 'a' received led 2 switched off
{
digitalwrite(ledpin = 2, high); // turn off pin 2
}
if ( val == 'a' ) // if 'a' received led 2 on
{
digitalwrite(ledpin = 2, low); // turn on pin 2
}
if ( val == 'b' ) // if 'b' received led 3 switched off
{
digitalwrite(ledpin = 3, high); // turn off pin 3
}
if ( val == 'b' ) // if 'b' received led 3 on
{
digitalwrite(ledpin = 3, low); // turn on pin 3
} //else (ledpin = 3, low) //set led pin 3 low state
if ( val == 'c' ) // if 'c' received led 2 on 1 second
{
digitalwrite(ledpin = 2, low); // turn on pin 2
delay(1000); // wait 1 second
digitalwrite(ledpin, high); // turn off pin 2
}
if ( val == 'd' ) // if 'd' received led 3 on 1 second
{
digitalwrite(ledpin = 3, low); // turn on pin 3
delay(1000); // wait 1 second
digitalwrite(ledpin, high); // turn off pin 3
}
if ( val == 'e' ) // if 'e' received led 2 on 5 seconds
{
digitalwrite(ledpin = 2, low); // turn on pin 2
delay(5000); // wait 500 milli seconds
digitalwrite(ledpin, high); // turn off pin 2
}
if ( val == 'f' ) // if 'f' received led 3 on 5 seconds
{
digitalwrite(ledpin = 3, low); // turn on pin 3
delay(5000); // wait 500 milli seconds
digitalwrite(ledpin, high); // turn off pin 3
}
if ( val == 'g' ) // if 'g' received turn led pin 2 on 500ms switch off , turn on pin 3 500 mili seconds off
{
digitalwrite(ledpin = 2, low); // turn on pin 2
delay(500); // wait 500mili second
digitalwrite(ledpin, high); // turn off pin 2
digitalwrite(ledpin = 3, low); // turn on pin 2
delay(500); // wait 500 mili second
digitalwrite(ledpin, high); // turn off pin 2
}
if ( val == 'h' ) // if 'h' received switch off pins
{
digitalwrite(ledpin = 13, low); // turn off pin 13
digitalwrite(ledpin = 2, high); // turn off pin 2
digitalwrite(ledpin = 3, high); // turn off pin 3
}
if ( val == 'h' ) // if 'h' received switch pin 2 on , off 1000 times
(int = 0; < 1000; i++)
{
digitalwrite(ledpin = 2, high); // turn on pin 2
delay (1000); //wait 1000 mili seconds
digitalwrite(ledpin = 2, low); // turn off pin 2
delay (1000); //wait 1000 mili seconds
}
expected } @ end of input
now because incredibly tired cant see it.
anyone shed light?
thanks!!
heres sketch
char val; // variable receive data serial port
int ledpin = 2; // led connected pin 2 (on-board led)
void setup()
{
pinmode(ledpin = 2, output); // pin 2 (on-board led) output
pinmode(ledpin = 3, output); // pin 3 (on-board led) output
serial.begin(9600); // start serial communication @ 115200bps
}
void loop()
{
if ( serial.available() ) // if data available read
{
;
}
val = serial.read(); // read , store in 'val'
if ( val == 'a' ) // if 'a' received led 2 switched off
{
digitalwrite(ledpin = 2, high); // turn off pin 2
}
if ( val == 'a' ) // if 'a' received led 2 on
{
digitalwrite(ledpin = 2, low); // turn on pin 2
}
if ( val == 'b' ) // if 'b' received led 3 switched off
{
digitalwrite(ledpin = 3, high); // turn off pin 3
}
if ( val == 'b' ) // if 'b' received led 3 on
{
digitalwrite(ledpin = 3, low); // turn on pin 3
} //else (ledpin = 3, low) //set led pin 3 low state
if ( val == 'c' ) // if 'c' received led 2 on 1 second
{
digitalwrite(ledpin = 2, low); // turn on pin 2
delay(1000); // wait 1 second
digitalwrite(ledpin, high); // turn off pin 2
}
if ( val == 'd' ) // if 'd' received led 3 on 1 second
{
digitalwrite(ledpin = 3, low); // turn on pin 3
delay(1000); // wait 1 second
digitalwrite(ledpin, high); // turn off pin 3
}
if ( val == 'e' ) // if 'e' received led 2 on 5 seconds
{
digitalwrite(ledpin = 2, low); // turn on pin 2
delay(5000); // wait 500 milli seconds
digitalwrite(ledpin, high); // turn off pin 2
}
if ( val == 'f' ) // if 'f' received led 3 on 5 seconds
{
digitalwrite(ledpin = 3, low); // turn on pin 3
delay(5000); // wait 500 milli seconds
digitalwrite(ledpin, high); // turn off pin 3
}
if ( val == 'g' ) // if 'g' received turn led pin 2 on 500ms switch off , turn on pin 3 500 mili seconds off
{
digitalwrite(ledpin = 2, low); // turn on pin 2
delay(500); // wait 500mili second
digitalwrite(ledpin, high); // turn off pin 2
digitalwrite(ledpin = 3, low); // turn on pin 2
delay(500); // wait 500 mili second
digitalwrite(ledpin, high); // turn off pin 2
}
if ( val == 'h' ) // if 'h' received switch off pins
{
digitalwrite(ledpin = 13, low); // turn off pin 13
digitalwrite(ledpin = 2, high); // turn off pin 2
digitalwrite(ledpin = 3, high); // turn off pin 3
}
if ( val == 'h' ) // if 'h' received switch pin 2 on , off 1000 times
(int = 0; < 1000; i++)
{
digitalwrite(ledpin = 2, high); // turn on pin 2
delay (1000); //wait 1000 mili seconds
digitalwrite(ledpin = 2, low); // turn off pin 2
delay (1000); //wait 1000 mili seconds
}
hi, need 1 last closing } , should fix it.
the last 1 @ moment part of last if statement.
you need 1 void loop().
tom...
the last 1 @ moment part of last if statement.
you need 1 void loop().
tom...
Arduino Forum > Using Arduino > Project Guidance > bluetooth relays, error compiling!!
arduino
Comments
Post a Comment