@@ -66,6 +66,7 @@ int lastCubeState = 0;
66
66
// Tasks (change these to what you're currently working on)
67
67
String taskOne = " Write Learn Guide" ;
68
68
String taskTwo = " Write Code" ;
69
+ String taskThree = " Taking a Break!" ;
69
70
70
71
// Adafruit IO Sending Delay, in seconds
71
72
int sendDelay = 0.5 ;
@@ -79,18 +80,17 @@ int minutes = 0;
79
80
void setup ()
80
81
{
81
82
// start the serial connection
82
- Serial.begin (115200 );
83
+ Serial.begin (9600 );
83
84
// wait for serial monitor to open
84
85
while (!Serial)
85
86
;
86
87
Serial.println (" Adafruit IO Time Tracking Cube" );
87
88
88
89
// disable low power mode on the prop-maker featherwing
89
90
Serial.println (" disabling low power mode..." );
90
- pinMode (9 , INPUT);
91
- Serial.println (" pin enabled" );
92
- digitalWrite (9 , HIGH);
91
+ pinMode (15 , OUTPUT);
93
92
Serial.println (" pin enabled" );
93
+ digitalWrite (15 , LOW);
94
94
95
95
// Initialize LIS3DH
96
96
if (!lis.begin (0x18 ))
@@ -102,11 +102,6 @@ void setup()
102
102
Serial.println (" LIS3DH found!" );
103
103
lis.setRange (LIS3DH_RANGE_4_G);
104
104
105
- // enable pin 9 - turn off low power mode
106
- // pinMode(9, OUTPUT);
107
- // digitalWrite(9, HIGH);
108
-
109
-
110
105
// This initializes the NeoPixel library.
111
106
// pixels.begin();
112
107
Serial.println (" Pixels init'd" );
@@ -164,31 +159,36 @@ void loop()
164
159
sensors_event_t event;
165
160
lis.getEvent (&event);
166
161
162
+
167
163
// Detect Cube Face Orientation
168
- if (event.acceleration .x > 9 && event.acceleration .x < 10 )
164
+ if (event.acceleration .x > 9 && event.acceleration .x < 10 ) // left-side up
169
165
{
170
166
// Serial.println("Cube TILTED: Left");
171
167
cubeState = 1 ;
172
168
}
173
- else if (event.acceleration .x < -9 )
169
+ else if (event.acceleration .x < -9 ) // right-side up
174
170
{
175
171
// Serial.println("Cube TILTED: Right");
176
172
cubeState = 2 ;
177
173
}
174
+ else if (event.acceleration .y < 0 && event.acceleration .y > -1 ) // top-side up
175
+ {
176
+ cubeState = 3 ;
177
+ }
178
178
else
179
179
{ // orientation not found
180
180
}
181
181
182
- // return if the value hasn't changed
182
+ // return if the orientation hasn't changed
183
183
if (cubeState == lastCubeState)
184
184
return ;
185
185
186
- // Send to Adafruit IO based off of the State
186
+ // Send to Adafruit IO based off of the orientation of the Cube
187
187
switch (cubeState)
188
188
{
189
189
case 1 :
190
190
Serial.println (" Switching to Task 1" );
191
- setPixels (0 , 150 , 0 );
191
+ // setPixels(0, 150, 0);
192
192
tone (PIEZO_PIN, 650 , 300 );
193
193
Serial.print (" Sending to Adafruit IO -> " );
194
194
Serial.println (taskTwo);
@@ -200,7 +200,7 @@ void loop()
200
200
break ;
201
201
case 2 :
202
202
Serial.println (" Switching to Task 2" );
203
- setPixels (150 , 0 , 0 );
203
+ // setPixels(150, 0, 0);
204
204
tone (PIEZO_PIN, 850 , 300 );
205
205
Serial.print (" Sending to Adafruit IO -> " );
206
206
Serial.println (taskOne);
@@ -210,6 +210,16 @@ void loop()
210
210
// reset the timer
211
211
minutes = 0 ;
212
212
break ;
213
+ case 3 :
214
+ Serial.println (" Switching to Task 3" );
215
+ tone (PIEZO_PIN, 950 , 300 );
216
+ Serial.print (" Sending to Adafruit IO -> " );
217
+ // prv task
218
+ // save previous task's minutes to a feed
219
+ cubeminutes -> save (minutes);
220
+ // reset the timer
221
+ minutes = 0 ;
222
+ break ;
213
223
}
214
224
215
225
// store last cube orientation state
0 commit comments