
ECE 4180 Design Project
Diff: main.cpp
- Revision:
- 0:6929ce2d0e6f
diff -r 000000000000 -r 6929ce2d0e6f main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Nov 26 15:26:04 2018 +0000 @@ -0,0 +1,52 @@ +#include "mbed.h" +#include "PinDetect.h" + +DigitalOut sprite(p17); +DigitalOut vodka(p15); +DigitalOut rum(p29); +DigitalOut coke(p28); +PinDetect VSbutton(p7); +PinDetect RCbutton(p5); + +void VSbutton_hit_callback (void) +{ + if (VSbutton == 0) + {vodka = 0; + wait(2.5); + vodka = 1;} + while(VSbutton == 0) + { + sprite = 0; + } + sprite = 1; +} + +void RCbutton_hit_callback (void) +{ + if (RCbutton == 0) + {rum = 0; + wait(2.5); + rum = 1;} + while(RCbutton == 0) + { + coke = 0; + } + coke = 1; +} + +int main() { + sprite = 1; + vodka = 1; + rum = 1; + coke = 1; + VSbutton.mode(PullUp); + RCbutton.mode(PullUp); + wait(0.1); + VSbutton.attach_deasserted(&VSbutton_hit_callback); + RCbutton.attach_deasserted(&RCbutton_hit_callback); + VSbutton.setSampleFrequency(); + RCbutton.setSampleFrequency(); + + while(1) + {}; + }