forked from deepunyk/smart_light
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtry.ino
More file actions
107 lines (98 loc) · 2.52 KB
/
try.ino
File metadata and controls
107 lines (98 loc) · 2.52 KB
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
//connect the pins to the pins metioned below, make sure that these pins mentioned here are nodemcu pins.
// Refer the pin diagram of nodemcu before connecting
// RGB strip which i have used is common cathode
#define RED_PIN 14
#define GREEN_PIN 12
#define BLUE_PIN 13
#define NORMAL_PIN 0
#define E1 4
#define E2 5
#include "config.h"
// Enter your adafruit feed name below inplace of feed name.
AdafruitIO_Feed *analog = io.feed("feedname");
void setup() {
pinMode (E1, OUTPUT);
pinMode (E2, OUTPUT);
pinMode (NORMAL_PIN, OUTPUT);
pinMode (BLUE_PIN, OUTPUT);
pinMode (RED_PIN, OUTPUT);
pinMode (GREEN_PIN, OUTPUT);
digitalWrite(E1, HIGH);
digitalWrite(E2, HIGH);
Serial.begin(115200);
while(! Serial);
Serial.print("Connecting to Adafruit IO");
io.connect();
analog->onMessage(handleMessage);
while(io.status() < AIO_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println();
Serial.println(io.statusText());
analog->get();
}
void loop() {
io.run();
}
void handleMessage(AdafruitIO_Data *data) {
int reading = data->toInt();
Serial.print("received <- ");
Serial.println(reading);
// for each button you press in remote you get one colour
if(reading == 16)
{
analogWrite (RED_PIN, 200);
analogWrite (GREEN_PIN, HIGH);
digitalWrite (BLUE_PIN, HIGH);
digitalWrite (NORMAL_PIN, HIGH);
}
else if(reading == 17)
{
digitalWrite (RED_PIN, HIGH);
digitalWrite (GREEN_PIN, LOW);
digitalWrite (BLUE_PIN, HIGH);
digitalWrite (NORMAL_PIN, HIGH);
}
else if(reading == 18)
{
digitalWrite (RED_PIN, HIGH);
digitalWrite (GREEN_PIN, HIGH);
digitalWrite (BLUE_PIN, LOW);
digitalWrite (NORMAL_PIN, HIGH);
}
else if(reading == 20)
{
digitalWrite (RED_PIN, HIGH);
digitalWrite (GREEN_PIN, LOW);
digitalWrite (BLUE_PIN, LOW);
digitalWrite (NORMAL_PIN, HIGH);
}
else if(reading == 21)
{
digitalWrite (RED_PIN, LOW);
digitalWrite (GREEN_PIN, HIGH);
digitalWrite (BLUE_PIN, LOW);
digitalWrite (NORMAL_PIN, HIGH);
}
else if(reading == 22)
{digitalWrite (RED_PIN, LOW);
digitalWrite (GREEN_PIN, LOW);
digitalWrite (BLUE_PIN, HIGH);
digitalWrite (NORMAL_PIN, HIGH);
}
else if(reading == 24)
{
digitalWrite (RED_PIN, LOW);
digitalWrite (GREEN_PIN, LOW);
digitalWrite (BLUE_PIN, LOW);
digitalWrite (NORMAL_PIN, HIGH);
}
else
{
digitalWrite (RED_PIN, HIGH);
digitalWrite (GREEN_PIN, HIGH);
digitalWrite (BLUE_PIN, HIGH);
digitalWrite (NORMAL_PIN, HIGH);
}
}