-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbluetooth_home.ino
137 lines (129 loc) · 5.43 KB
/
bluetooth_home.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#include "FastLED.h"
/*
* Bluetooh Basic: LED ON OFF - Avishkar
* more data to be added soon
* Coder - Mayoogh Girish
* Website - http://bit.do/Avishkar
* Download the App : https://github.com/Mayoogh/Arduino-Bluetooth-Basic
* This program lets you to control a LED on pin 13 of arduino using a bluetooth module
*/
#define NUM_LEDS 50
#define DATA_PIN 3
#define CLOCK_PIN 8
CRGB leds[NUM_LEDS];
char data = 0; //Variable for storing received data
void setup()
{ delay(2000);
Serial.begin(9600); //Sets the baud for serial data transmission
//pinMode(13, OUTPUT); //Sets digital pin 13 as output pin
FastLED.addLeds<SM16716, DATA_PIN, CLOCK_PIN, RGB>(leds, NUM_LEDS);
FastLED.show();
}
void loop()
{
if(Serial.available() > 0) // Send data only when you receive data:
{
data = Serial.read(); //Read the incoming data & store into data
Serial.print(data); //Print Value inside data in Serial monitor
Serial.print("\n");
if(data == 'A') // Checks whether value of data is equal to 1
{leds[0] = CRGB::White;
leds[1] = CRGB::White;
leds[2] = CRGB::White;
leds[3] = CRGB::White;
//digitalWrite(13, HIGH); //If value is 1 then LED turns ON
}
else if(data == 'a') // Checks whether value of data is equal to 0
{ leds[0] = CRGB::Black;
leds[1] = CRGB::Black;
leds[2] = CRGB::Black;
leds[3] = CRGB::Black;
//digitalWrite(13, LOW); //If value is 0 then LED turns OFF
}
else if(data == 'B') // Checks whether value of data is equal to 1
{leds[5] = CRGB::White;
leds[6] = CRGB::White;
leds[7] = CRGB::White;
leds[8] = CRGB::White;
leds[9] = CRGB::White;
//digitalWrite(13, HIGH); //If value is 1 then LED turns ON
}
else if(data == 'b') // Checks whether value of data is equal to 0
{ leds[5] = CRGB::Black;
leds[6] = CRGB::Black;
leds[7] = CRGB::Black;
leds[8] = CRGB::Black;
leds[9] = CRGB::Black;
//digitalWrite(13, LOW); //If value is 0 then LED turns OFF
}
else if(data == 'C') // Checks whether value of data is equal to 1
{leds[12] = CRGB::White;
leds[13] = CRGB::White;
leds[15] = CRGB::White;
leds[16] = CRGB::White;
//digitalWrite(13, HIGH); //If value is 1 then LED turns ON
}
else if(data == 'c') // Checks whether value of data is equal to 0
{leds[12] = CRGB::Black;
leds[13] = CRGB::Black;
leds[15] = CRGB::Black;
leds[16] = CRGB::Black;
//digitalWrite(13, LOW); //If value is 0 then LED turns OFF
}
else if(data == 'D') // Checks whether value of data is equal to 1
{leds[17] = CRGB::White;
leds[18] = CRGB::White;
leds[19] = CRGB::White;
//digitalWrite(13, HIGH); //If value is 1 then LED turns ON
}
else if(data == 'd') // Checks whether value of data is equal to 0
{leds[17] = CRGB::Black;
leds[18] = CRGB::Black;
leds[19] = CRGB::Black;
//digitalWrite(13, LOW); //If value is 0 then LED turns OFF
}
else if(data == 'E') // Checks whether value of data is equal to 1
{leds[20] = CRGB::White;
leds[21] = CRGB::White;
leds[22] = CRGB::White;
//digitalWrite(13, HIGH); //If value is 1 then LED turns ON
}
else if(data == 'e') // Checks whether value of data is equal to 0
{leds[20] = CRGB::Black;
leds[21] = CRGB::Black;
leds[22] = CRGB::Black;
//digitalWrite(13, LOW); //If value is 0 then LED turns OFF
}
else if(data == 'F') // Checks whether value of data is equal to 1
{leds[23] = CRGB::White;
//digitalWrite(13, HIGH); //If value is 1 then LED turns ON
}
else if(data == 'f') // Checks whether value of data is equal to 0
{ leds[23] = CRGB::Black;
//digitalWrite(13, LOW); //If value is 0 then LED turns OFF
}
else if(data == 'G') // Checks whether value of data is equal to 1
{leds[24] = CRGB::White;
//digitalWrite(13, HIGH); //If value is 1 then LED turns ON
}
else if(data == 'g') // Checks whether value of data is equal to 0
{ leds[24] = CRGB::Black;
//digitalWrite(13, LOW); //If value is 0 then LED turns OFF
}
else if(data == 'H') // Checks whether value of data is equal to 1
{leds[25] = CRGB::White;
leds[26] = CRGB::White;
leds[27] = CRGB::White;
leds[28] = CRGB::White;
//digitalWrite(13, HIGH); //If value is 1 then LED turns ON
}
else if(data == 'h') // Checks whether value of data is equal to 0
{ leds[25] = CRGB::Black;
leds[26] = CRGB::Black;
leds[27] = CRGB::Black;
leds[28] = CRGB::Black;
//digitalWrite(13, LOW); //If value is 0 then LED turns OFF
}
FastLED.show();
}
}