Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Timer by
Diff: main.cpp
- Revision:
- 1:f5ee66d417f8
- Parent:
- 0:71df4c1d3c09
- Child:
- 2:4322a370e8d1
--- a/main.cpp Tue Jul 28 08:15:02 2015 +0000
+++ b/main.cpp Thu Jul 30 08:03:01 2015 +0000
@@ -2,6 +2,7 @@
#include "Display.h"
#define Sound 0xA0
+#define Servo 0x88
Ticker t;
DigitalIn Button_Launch(D1);
@@ -11,7 +12,6 @@
DigitalOut LED_Timer (D3);
DigitalOut LED_Finish (D4);
DigitalOut LED_Launch (D5);
-PwmOut ServoOut (D10);
DigitalIn Camera (D9);
I2C i2c(PTE25, PTE24); // sda, scl
@@ -21,10 +21,6 @@
int Time; //time in 10mS
int timer; //Stores timer mode
-void Servo(int deg){
- ServoOut = 0.13f-(float(deg)/1900);
-}
-
int main()
{
int count=0;
@@ -37,19 +33,24 @@
timer=Reset; //Reset timer
t.attach(&DisplayUpdate, 0.01); //Set the timer function as a ticker.
+ /*
+ while(1){
+ char cmd[4]={1,2,3,4};
+ i2c.write(Servo, cmd, 1);
+ }
+ */
+
//DisplayScroll("dont crash get a badge");
//timer=Reset;
-
- char n='F';
- i2c.write(Sound, &n, 1);
-
while(true){
count++;
if(count>150000){
count=0;
if(timer==Reset){
LED_Launch=!LED_Launch;
+ }else{
+ LED_Launch=0;
}
}
@@ -65,17 +66,51 @@
LED_Finish=0;
}
- if(!Button_Launch){
- char n='s';
- timer=Start;
+ if(!Button_Launch && timer==Start){
+ Time+=1000;
+ wait(0.1f);
+ while(!Button_Launch){}
+ wait(0.1f);
+ }
+
+ if(!Button_Launch && timer==Reset){
+ char n='S';
+ LED_Launch=0;
+ wait(1);
+
+ if(!Button_Sel1){
+ i2c.write(Sound, &n, 1);//Start sound
+ }
+
+ wait(0.5); //Flashing to sync with sound
LED_Launch=1;
- i2c.write(Sound, &n, 1);
- }else if(timer!=Reset){
+ DisplayNumber(15,15,3,15,15);
+ wait(0.5);
+ LED_Launch=0;
+ wait(0.5);
+ LED_Launch=1;
+ DisplayNumber(15,15,2,15,15);
+ wait(0.5);
LED_Launch=0;
+ wait(0.5);
+ LED_Launch=1;
+ DisplayNumber(15,15,1,15,15);
+ wait(0.5);
+ LED_Launch=0;
+ wait(0.5);
+ LED_Launch=1;
+ timer=Start; //Start the timer
+ LED_Timer=1;
+ wait(2);
+ LED_Launch=0; //Turn off the light
}
if(Button_Reset&&(timer==Start)){
+ char n='F';
timer=Pause;
+ if(!Button_Sel1){
+ i2c.write(Sound, &n, 1); //End sound
+ }
wait(0.1f);
while(Button_Reset){}
wait(0.1f);
@@ -85,8 +120,12 @@
timer=Reset;
}
- if(Camera){
+ if(Camera && (timer==Start)){
+ char n='F';
timer=Pause;
+ if(!Button_Sel1){
+ i2c.write(Sound, &n, 1); //End sound
+ }
}
}
