Sparki the snooze alarm-improvement

So my last post I shared the code to turn Sparki into a “snooze alarm” – the alarm you set for ten minutes after your actual alarm goes off while you doze back to sleep.

In this post I’m going to share the improvements I made after re-looking at the code, using the light sensors as a button to switch off the alarm if you are awake, or else it continues so that you do wake up.

#include <Sparki.h> // include the sparki library

void setup() {
 sparki.RGB(RGB_OFF);
 sparki.servo(60);
}
void loop()
{
 
 for (int i = 0; i < 6; i=i+1)
 {
 delay (100000);
 sparki.moveLeft(30);
 sparki.moveRight(30);
 }
 sparki.clearLCD();
 sparki.drawString(10,2, "Good morning Ash");
 sparki.updateLCD();
 delay (3000);
 for (int i = 0; i < 10; i=i+1)
 {
 int left = sparki.lightLeft();
 int right = sparki.lightRight();
 if (left>=right)
 {
 sparki.beep(740, 600);
 delay(400);
 sparki.beep(540, 400);
 delay(400);
 sparki.beep(540, 200);
 delay(200);
 sparki.beep(440, 200);
 delay(200);
 sparki.beep(640, 400);
 delay(400);
 sparki.beep(740, 200);
 delay(400);
 sparki.beep(740, 200);
 }}
 sparki.clearLCD();
 sparki.drawString(10,2, "Hope you have a good day");
 sparki.updateLCD();
 delay (3000);
 sparki.clearLCD();
 sparki.drawString(10,2, "ha en fin dag");
 sparki.updateLCD();
 delay (3000);
}

Let me know what you think šŸ™‚

I cant believe how versatile Sparki is- can be used for soooo many things šŸ™‚ šŸ™‚

13151622_10208751226194601_4580888961498116869_n

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s