2929#define PIEZO_PIN 0
3030
3131// NeoPixel Pin on Prop-Maker FeatherWing
32- #define PIN 5
32+ #define NEOPIXEL_PIN 5
3333
3434// # 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
3643
3744// 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);
3946
4047// Used for software SPI
4148#define LIS3DH_CLK 13
@@ -86,12 +93,18 @@ void setup()
8693 ;
8794 Serial.println (" Adafruit IO Time Tracking Cube" );
8895
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+
95108 // Initialize LIS3DH
96109 if (!lis.begin (0x18 ))
97110 {
@@ -103,7 +116,7 @@ void setup()
103116 lis.setRange (LIS3DH_RANGE_4_G);
104117
105118 // This initializes the NeoPixel library.
106- // pixels .begin();
119+ strip .begin ();
107120 Serial.println (" Pixels init'd" );
108121
109122 // connect to io.adafruit.com
@@ -123,15 +136,6 @@ void setup()
123136
124137}
125138
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-
135139void updateTime ()
136140{
137141 currentTime = millis () / 1000 ;
@@ -144,6 +148,19 @@ void updateTime()
144148 }
145149}
146150
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+
147164void loop ()
148165{
149166 // io.run(); is required for all sketches.
@@ -183,12 +200,13 @@ void loop()
183200 if (cubeState == lastCubeState)
184201 return ;
185202
203+
186204 // Send to Adafruit IO based off of the orientation of the Cube
187205 switch (cubeState)
188206 {
189207 case 1 :
190208 Serial.println (" Switching to Task 1" );
191- // setPixels(0, 150 , 0);
209+ updatePixels ( 50 , 0 , 0 );
192210 tone (PIEZO_PIN, 650 , 300 );
193211 Serial.print (" Sending to Adafruit IO -> " );
194212 Serial.println (taskTwo);
@@ -200,7 +218,7 @@ void loop()
200218 break ;
201219 case 2 :
202220 Serial.println (" Switching to Task 2" );
203- // setPixels(150, 0 , 0);
221+ updatePixels ( 0 , 50 , 0 );
204222 tone (PIEZO_PIN, 850 , 300 );
205223 Serial.print (" Sending to Adafruit IO -> " );
206224 Serial.println (taskOne);
@@ -212,6 +230,7 @@ void loop()
212230 break ;
213231 case 3 :
214232 Serial.println (" Switching to Task 3" );
233+ updatePixels (0 , 0 , 50 );
215234 tone (PIEZO_PIN, 950 , 300 );
216235 Serial.print (" Sending to Adafruit IO -> " );
217236 // prv task
0 commit comments