Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int ledPin = 9;
- int state = 0;
- void setup() {
- pinMode(ledPin, OUTPUT);
- digitalWrite(ledPin, LOW);
- Serial.begin(38400); // Default communication rate of the Bluetooth module
- }
- void loop() {
- if(Serial.available()){ // if data available at serial port
- state = Serial.read(); // assign incoming data to variable state
- Serial.println(Serial.read());
- }
- // Controlling the LED
- if (state == '1') {
- digitalWrite(ledPin, HIGH); // LED ON ;
- }
- else if (state == '0') {
- digitalWrite(ledPin, LOW); // LED ON ;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement