assignment 6 360- part 1 is complete-freeze balls on lcd screen with a hardware interrupt/button
Dependencies: 4DGL-uLCD-SE MMA8452Q_withfreefall bouncing_ball mbed
Fork of Assignment6 by
Diff: main.cpp
- Revision:
- 5:62b2d643b132
- Parent:
- 3:a7f02754bc99
--- a/main.cpp Tue Nov 07 13:24:50 2017 +0000 +++ b/main.cpp Thu Dec 07 14:51:51 2017 +0000 @@ -1,8 +1,3 @@ -// A solution to OCE360 Homework #4. -// Objective: Use object oriented programming to create a system that displays -// multiple balls bouncing around the LCD screen. -// Stephen Licht, 11/7/2017 - #include "mbed.h" #include "MMA8452Q.h" //acceleromater library #include "uLCD_4DGL.h" //LCD library @@ -30,8 +25,27 @@ physics_ball ball1; //initialize two balls for bouncing physics_ball ball2; //the default states from the library will be used initially +// External Interrupts +InterruptIn button(p18); +InterruptIn freefall_acc(p17); +Timer debounce; + + +// Response to the hardware interrupt(button being pressed), set speed of balls = 0 +void Freeze_button(){ + ball1.set_state(ball1.posx, ball1.posy,0,0); + ball2.set_state(ball2.posx, ball2.posy,0,0); + wait(2); + debounce.reset(); + } +//void Freeze_ff(){ + //if + int main() { + button.mode(PullUp); // use internal resistors in button in order to keep output reading "high", then when button switched it will fall + button.fall(&Freeze_button); //freeze accelerometer for 2 sec when button is pressed + // Initialize uLCD uLCD.baudrate(115200); uLCD.background_color(BLACK);