SHARE
TWEET

4-LED BT Control

Attilator Jan 23rd, 2020 (edited) 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //#include <SoftwareSerial.h>
  2. //int bluetoothTx = 12;//bluetooth module terminal TX
  3. //int bluetoothRx = 11;//bluetooth module terminal RX
  4. //SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);
  5.  
  6. void setup() {
  7.  Serial.begin(9600);
  8. // bluetooth.begin(9600);
  9.  
  10.  pinMode(7, OUTPUT);
  11.  pinMode(8, OUTPUT);
  12.  pinMode(9, OUTPUT);
  13.  pinMode(10, OUTPUT);
  14.  digitalWrite(7, LOW);
  15.  digitalWrite(8, LOW);
  16.  digitalWrite(9, LOW);
  17.  digitalWrite(10, LOW);
  18.   }
  19.  
  20.  
  21. void loop() {
  22.    if(Serial.available()>0)
  23.    {    
  24.       char x = Serial.read();
  25.       switch(x)
  26.       {
  27.         case 'a': digitalWrite(7, HIGH);digitalWrite(8, HIGH);digitalWrite(9, HIGH);digitalWrite(10, HIGH);break;
  28.         case 'r': digitalWrite(7, HIGH); /*Serial.println("Red LED is on");*/ /*bluetooth.print('R');*/ break;
  29.         case 's': digitalWrite(7, LOW);break;
  30.         case 'g': digitalWrite(8, HIGH);break;
  31.         case 'h': digitalWrite(8, LOW);break;
  32.         case 'y': digitalWrite(9, HIGH);break;
  33.         case 'z': digitalWrite(9, LOW);break;
  34.         case 'b': digitalWrite(10, HIGH);break;
  35.         case 'c': digitalWrite(10, LOW);break;
  36.         case 'x': digitalWrite(7, LOW);digitalWrite(8, LOW);digitalWrite(9, LOW);digitalWrite(10, LOW);break;
  37.         default : break;
  38.       }
  39.         delay(50);
  40.    } //end switch
  41. } //end loop
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top