Simple starter skeleton for asteroids video game.

Dependencies:   PinDetect

main.cpp

Committer:
jhurley31
Date:
2019-02-21
Revision:
0:0c450cb95a1e
Child:
1:a6872783beca

File content as of revision 0:0c450cb95a1e:

#include "mbed.h"
#include "Speaker.h"
#include "PinDetect.h"

// Setup push button pins
PinDetect pb_left(p16); 
PinDetect pb_right(p17); 
PinDetect pb_up(p18);
PinDetect pb_down(p18);
// setup instance of new Speaker class, mySpeaker using pin 21
// the pin must be a PWM output pin
Speaker mySpeaker(p21);
//---------------------------------------------------------------------------------------------------
// Callback routine is interrupt activated by a debounced pb_left hit
// That is … this code runs with interrupt is generated by first button press
void pb_left_hit_callback (void)
{
    // Tell Buzzman to go left
    //*************
    // Fill in needed Code here
    //*************

}
//---------------------------------------------------------------------------------------------------
// Callback routine is interrupt activated by a debounced pb_right hit
// That is … this code runs with interrupt is generated by first button press
void pb_right_hit_callback (void)
{
    // Tell Buzzman to go right
    //*************
    // Fill in needed Code here
    //*************

}
//---------------------------------------------------------------------------------------------------
int main()
{
//setup push buttons
pb1.mode(PullUp);
pb2.mode(PullUp);
pb3.mode(PullUp);
// Delay for initial pullup to take effect
wait(.01);
// Setup Interrupt callback functions for a pb hit
pb1.attach_deasserted(&pb1_hit_callback);
pb2.attach_deasserted(&pb2_hit_callback);
pb3.attach_deasserted(&pb3_hit_callback);
// Start sampling pb inputs using interrupts
pb1.setSampleFrequency();
pb2.setSampleFrequency();
pb3.setSampleFrequency();
// pushbuttons now setup and running
while(1)
{
myled4 = !myled4;
wait(0.5);
}
} //end main