Sparki the Timer Robot

So after working on Sparki the snooze alarm I decided to experiment with Sparki the Timer Robot.

In the following code I gave the user the option of setting a five minute alarm or a ten minute alarm using Sparki’s light sensors as buttons. I find that five minute and ten minute alarms are most commonly used for cooking, timers, and children (lol) so thought that would be the most helpful.

I enjoyed writing this but I think I will edit the code so that the alarm sounds for longer but the user has the option to “switch” it off earlier.

13221667_10208793227204600_8850987448344265824_n

Here is the code, let me know what you think 🙂 🙂

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

void setup() {
 sparki.RGB(RGB_OFF);
 sparki.servo(60);
}
void loop()
{
 sparki.beep(640, 400);
 delay(500);
 sparki.beep(340,400);
 delay(500);
 sparki.clearLCD();
 sparki.drawString(10,2, "Hello");
 sparki.updateLCD();
 delay (5000);
 sparki.clearLCD();
 sparki.drawString(10,2, "Would you like to set an alarm?");
 sparki.updateLCD();
 delay (5000);
 int left = sparki.lightLeft();
 int right = sparki.lightRight();
 if (left>=right)
 {
 sparki.clearLCD();
 sparki.drawString(10,2, "Choose Right for five minutes");
 sparki.updateLCD();
 delay (5000);
 sparki.clearLCD();
 sparki.drawString(10,2, "Choose Left for ten minutes");
 sparki.updateLCD();
 delay (5000);
 sparki.clearLCD();
 sparki.drawString(10,2, "Right (5) or Left (10)");
 sparki.updateLCD();
 delay (5000);
 int left = sparki.lightLeft();
 int right = sparki.lightRight();
 if (left>=right)
 {
 sparki.clearLCD();
 sparki.drawString(10,2, "5 minute alarm set");
 sparki.updateLCD();
 delay (3000);
 for (int i = 0; i < 3; i=i+1)
 {
 delay (100000);
 sparki.moveLeft(30);
 sparki.moveRight(30);
 }
 sparki.clearLCD();
 sparki.drawString(10,2, "Alarm time reached");
 sparki.updateLCD();
 delay (5000);
 for (int i = 0; i < 10; i=i+1)
 {
 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);
 }
}delay (100000);
 if (left<right)
 {
 sparki.clearLCD();
 sparki.drawString(10,2, "10 minute alarm set");
 sparki.updateLCD();
 delay (5000);
 for (int i = 0; i < 6; i=i+1)
 {
 delay (100000);
 sparki.moveLeft(30);
 sparki.moveRight(30);
 }
 sparki.clearLCD();
 sparki.drawString(10,2, "Alarm time reached");
 sparki.updateLCD();
 delay (5000);
 for (int i = 0; i < 10; i=i+1)
 {
 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);
 }
 }delay (100000);
 }
 
 sparki.clearLCD();
 sparki.drawString(10,2, "Ok maybe later");
 sparki.updateLCD();
 delay (5000);
 sparki.beep(450,400);
 delay(500);
 sparki.beep(750,400);
delay(500);
delay (100000);
}


Advertisements

Eight . . .

Originally posted on Ctrl. Alt. Believe. :
Forty-Five! I blinked in disbelief! Forty-Five waypoints just for basic HTML5 and CSS alone! I am referring to the revamped curriculum offered by FreeCodeCamp.com.  This website is completely free and takes the user step by step through the technologies that are necessary to master in order to become a…

First post :)

Hi guys

so this is my first blog and as you’ve probably guessed I’m ashbot so hey 🙂 and I thought I’d start by introducing the other half of the team, Sparki.

DSC_0065

Sparki is an arcbotics robot which offers a really good intro to programming. He has an led, buzzer, grippers, ultrasonic range finder, stepper motors, lcd screen, bluetooth chip, remote control and so much more..the crazy bot can even draw!!…the arcbotics website can tell you so much more.

http://arcbotics.com/products/sparki/

I was a total n00b to programming but now I feel quite confident, and in my actual job I help others learn with Sparki too. I think this little guy is awesome and as I’m totally geeky over it I thought I’d document my progress as a blog. I will upload code examples and videos of the capabilities of this guy and I hope you all enjoy 😀