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
main.cpp
- Committer:
- Jamestom999
- Date:
- 2015-07-28
- Revision:
- 0:71df4c1d3c09
- Child:
- 1:f5ee66d417f8
File content as of revision 0:71df4c1d3c09:
#include "mbed.h"
#include "Display.h"
#define Sound 0xA0
Ticker t;
DigitalIn Button_Launch(D1);
DigitalIn Button_Reset (D0);
DigitalIn Button_Sel1 (D6);
DigitalIn Button_Sel2 (D7);
DigitalOut LED_Timer (D3);
DigitalOut LED_Finish (D4);
DigitalOut LED_Launch (D5);
PwmOut ServoOut (D10);
DigitalIn Camera (D9);
I2C i2c(PTE25, PTE24); // sda, scl
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;
wait(0.5); //Allow other IC's to power up
DisplayInit();
//--------------------------Timer-----------------------------
Time=0; //reset time.
timer=Reset; //Reset timer
t.attach(&DisplayUpdate, 0.01); //Set the timer function as a ticker.
//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;
}
}
if(timer==Start){
LED_Timer=1;
}else{
LED_Timer=0;
}
if(timer==Pause){
LED_Finish=1;
}else{
LED_Finish=0;
}
if(!Button_Launch){
char n='s';
timer=Start;
LED_Launch=1;
i2c.write(Sound, &n, 1);
}else if(timer!=Reset){
LED_Launch=0;
}
if(Button_Reset&&(timer==Start)){
timer=Pause;
wait(0.1f);
while(Button_Reset){}
wait(0.1f);
}
if(Button_Reset&&(timer==Pause)){
timer=Reset;
}
if(Camera){
timer=Pause;
}
}
}
