@@ -66,6 +66,7 @@ int lastCubeState = 0;
6666// Tasks (change these to what you're currently working on)
6767String taskOne = " Write Learn Guide" ;
6868String taskTwo = " Write Code" ;
69+ String taskThree = " Taking a Break!" ;
6970
7071// Adafruit IO Sending Delay, in seconds
7172int sendDelay = 0.5 ;
@@ -79,18 +80,17 @@ int minutes = 0;
7980void setup ()
8081{
8182 // start the serial connection
82- Serial.begin (115200 );
83+ Serial.begin (9600 );
8384 // wait for serial monitor to open
8485 while (!Serial)
8586 ;
8687 Serial.println (" Adafruit IO Time Tracking Cube" );
8788
8889 // disable low power mode on the prop-maker featherwing
8990 Serial.println (" disabling low power mode..." );
90- pinMode (9 , INPUT);
91- Serial.println (" pin enabled" );
92- digitalWrite (9 , HIGH);
91+ pinMode (15 , OUTPUT);
9392 Serial.println (" pin enabled" );
93+ digitalWrite (15 , LOW);
9494
9595 // Initialize LIS3DH
9696 if (!lis.begin (0x18 ))
@@ -102,11 +102,6 @@ void setup()
102102 Serial.println (" LIS3DH found!" );
103103 lis.setRange (LIS3DH_RANGE_4_G);
104104
105- // enable pin 9 - turn off low power mode
106- // pinMode(9, OUTPUT);
107- // digitalWrite(9, HIGH);
108-
109-
110105 // This initializes the NeoPixel library.
111106 // pixels.begin();
112107 Serial.println (" Pixels init'd" );
@@ -164,31 +159,36 @@ void loop()
164159 sensors_event_t event;
165160 lis.getEvent (&event);
166161
162+
167163 // 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
169165 {
170166 // Serial.println("Cube TILTED: Left");
171167 cubeState = 1 ;
172168 }
173- else if (event.acceleration .x < -9 )
169+ else if (event.acceleration .x < -9 ) // right-side up
174170 {
175171 // Serial.println("Cube TILTED: Right");
176172 cubeState = 2 ;
177173 }
174+ else if (event.acceleration .y < 0 && event.acceleration .y > -1 ) // top-side up
175+ {
176+ cubeState = 3 ;
177+ }
178178 else
179179 { // orientation not found
180180 }
181181
182- // return if the value hasn't changed
182+ // return if the orientation hasn't changed
183183 if (cubeState == lastCubeState)
184184 return ;
185185
186- // Send to Adafruit IO based off of the State
186+ // Send to Adafruit IO based off of the orientation of the Cube
187187 switch (cubeState)
188188 {
189189 case 1 :
190190 Serial.println (" Switching to Task 1" );
191- setPixels (0 , 150 , 0 );
191+ // setPixels(0, 150, 0);
192192 tone (PIEZO_PIN, 650 , 300 );
193193 Serial.print (" Sending to Adafruit IO -> " );
194194 Serial.println (taskTwo);
@@ -200,7 +200,7 @@ void loop()
200200 break ;
201201 case 2 :
202202 Serial.println (" Switching to Task 2" );
203- setPixels (150 , 0 , 0 );
203+ // setPixels(150, 0, 0);
204204 tone (PIEZO_PIN, 850 , 300 );
205205 Serial.print (" Sending to Adafruit IO -> " );
206206 Serial.println (taskOne);
@@ -210,6 +210,16 @@ void loop()
210210 // reset the timer
211211 minutes = 0 ;
212212 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 ;
213223 }
214224
215225 // store last cube orientation state
0 commit comments