Reid Clyburn / Mbed 2 deprecated DesignProject

Dependencies:   mbed PinDetect

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "PinDetect.h"
00003 
00004 DigitalOut sprite(p17);
00005 DigitalOut vodka(p15);
00006 DigitalOut rum(p29);
00007 DigitalOut coke(p28);
00008 PinDetect VSbutton(p7);
00009 PinDetect RCbutton(p5);
00010 
00011 void VSbutton_hit_callback (void)
00012 { 
00013     if (VSbutton == 0)
00014         {vodka = 0;
00015          wait(2.5);
00016          vodka = 1;}
00017         while(VSbutton == 0)
00018         {
00019             sprite = 0;
00020         }
00021         sprite = 1;
00022 }
00023 
00024 void RCbutton_hit_callback (void)
00025 { 
00026     if (RCbutton == 0)
00027         {rum = 0;
00028          wait(2.5);
00029          rum = 1;}
00030         while(RCbutton == 0)
00031         {
00032             coke = 0;
00033         }
00034         coke = 1;
00035 }
00036 
00037 int main() {
00038   sprite = 1;
00039   vodka = 1;
00040   rum = 1;
00041   coke = 1;
00042   VSbutton.mode(PullUp);
00043   RCbutton.mode(PullUp);
00044   wait(0.1);
00045   VSbutton.attach_deasserted(&VSbutton_hit_callback);
00046   RCbutton.attach_deasserted(&RCbutton_hit_callback);
00047   VSbutton.setSampleFrequency();
00048   RCbutton.setSampleFrequency();
00049   
00050   while(1)
00051   {};
00052  }