29
29
#define PIEZO_PIN 0
30
30
31
31
// NeoPixel Pin on Prop-Maker FeatherWing
32
- #define PIN 5
32
+ #define NEOPIXEL_PIN 5
33
33
34
34
// # of Pixels Attached
35
- #define NUMPIXELS 8
35
+ #define NUM_PIXELS 8
36
+
37
+ // Prop-Maker Wing
38
+ #define NEOPIXEL_PIN 2
39
+ #define POWER_PIN 15
40
+ #define RED_LED 13
41
+ #define GREEN_LED 12
42
+ #define BLUE_LED 14
36
43
37
44
// Library Setup
38
- Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN , NEO_GRB + NEO_KHZ800);
45
+ Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_PIXELS, NEOPIXEL_PIN , NEO_GRB + NEO_KHZ800);
39
46
40
47
// Used for software SPI
41
48
#define LIS3DH_CLK 13
@@ -86,12 +93,18 @@ void setup()
86
93
;
87
94
Serial.println (" Adafruit IO Time Tracking Cube" );
88
95
89
- // disable low power mode on the prop-maker featherwing
90
- Serial.println (" disabling low power mode..." );
91
- pinMode (15 , OUTPUT);
92
- Serial.println (" pin enabled" );
93
- digitalWrite (15 , LOW);
94
-
96
+ // Enabling NeoPixel and PWR mode
97
+ pinMode (POWER_PIN, OUTPUT);
98
+ digitalWrite (POWER_PIN, LOW);
99
+ pinMode (RED_LED, OUTPUT);
100
+ pinMode (GREEN_LED, OUTPUT);
101
+ pinMode (BLUE_LED, OUTPUT);
102
+
103
+ analogWrite (RED_LED, 0 );
104
+ analogWrite (GREEN_LED, 0 );
105
+ analogWrite (BLUE_LED, 0 );
106
+
107
+
95
108
// Initialize LIS3DH
96
109
if (!lis.begin (0x18 ))
97
110
{
@@ -103,7 +116,7 @@ void setup()
103
116
lis.setRange (LIS3DH_RANGE_4_G);
104
117
105
118
// This initializes the NeoPixel library.
106
- // pixels .begin();
119
+ strip .begin ();
107
120
Serial.println (" Pixels init'd" );
108
121
109
122
// connect to io.adafruit.com
@@ -123,15 +136,6 @@ void setup()
123
136
124
137
}
125
138
126
- void setPixels (int red, int green, int blue) {
127
- for (int i=0 ;i<NUMPIXELS;i++){
128
- // pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
129
- pixels.setPixelColor (i, pixels.Color (red,green,blue)); // Moderately bright green color.
130
- pixels.show (); // This sends the updated pixel color to the hardware.
131
- delay (500 ); // Delay for a period of time (in milliseconds).
132
- }
133
- }
134
-
135
139
void updateTime ()
136
140
{
137
141
currentTime = millis () / 1000 ;
@@ -144,6 +148,19 @@ void updateTime()
144
148
}
145
149
}
146
150
151
+ void updatePixels (uint8_t red, uint8_t green, uint8_t blue)
152
+ {
153
+ // Power on the prop maker wing
154
+ digitalWrite (POWER_PIN, HIGH);
155
+ analogWrite (RED_LED, 0 );
156
+ analogWrite (GREEN_LED, 0 );
157
+ analogWrite (BLUE_LED, 0 );
158
+ for (int p=0 ; p<NUM_PIXELS; p++) {
159
+ strip.setPixelColor (p, red, green, blue);
160
+ }
161
+ strip.show ();
162
+ }
163
+
147
164
void loop ()
148
165
{
149
166
// io.run(); is required for all sketches.
@@ -183,12 +200,13 @@ void loop()
183
200
if (cubeState == lastCubeState)
184
201
return ;
185
202
203
+
186
204
// Send to Adafruit IO based off of the orientation of the Cube
187
205
switch (cubeState)
188
206
{
189
207
case 1 :
190
208
Serial.println (" Switching to Task 1" );
191
- // setPixels(0, 150 , 0);
209
+ updatePixels ( 50 , 0 , 0 );
192
210
tone (PIEZO_PIN, 650 , 300 );
193
211
Serial.print (" Sending to Adafruit IO -> " );
194
212
Serial.println (taskTwo);
@@ -200,7 +218,7 @@ void loop()
200
218
break ;
201
219
case 2 :
202
220
Serial.println (" Switching to Task 2" );
203
- // setPixels(150, 0 , 0);
221
+ updatePixels ( 0 , 50 , 0 );
204
222
tone (PIEZO_PIN, 850 , 300 );
205
223
Serial.print (" Sending to Adafruit IO -> " );
206
224
Serial.println (taskOne);
@@ -212,6 +230,7 @@ void loop()
212
230
break ;
213
231
case 3 :
214
232
Serial.println (" Switching to Task 3" );
233
+ updatePixels (0 , 0 , 50 );
215
234
tone (PIEZO_PIN, 950 , 300 );
216
235
Serial.print (" Sending to Adafruit IO -> " );
217
236
// prv task
0 commit comments