Question: Consider a push button being connected to p16 on the mbed LPC1768 board so that p16 will be set to 1 when the push button
Consider a push button being connected to p16 on the mbed LPC1768 board so that p16 will be set to 1 when the push button is pushed down and 0 when the push button is released. Write a program to receive the push down of the push button as an interrupt event, and to respond to it with the starting of a ticker to flash the LED4 on the mbed board to flash every 10 seconds (on for 5 seconds and off for 5 seconds). Please do not use any wait(), wait_ms() or wait_us() functions.
The following are the API information:
InterruptIn API:
InterruptIn (PinName pin)
Create an InterruptIn connected to the specified pin.
void rise (void(*fptr)(void))
Attach a function to call when a rising edge occurs on the input.
void fall (void(*fptr)(void))
Attach a function to call when a falling edge occurs on the input.
void mode (PinMode pull)
Set the input pin mode.
----------------------------------------------------------------------------
Timer API
void start ()
Start the timer.
void stop ()
Stop the timer.
void reset ()
Reset the timer to 0.
float read ()
Get the time passed in seconds.
int read_ms ()
Get the time passed in mili-seconds.
int read_us ()
Get the time passed in micro-seconds.
--------------------------------------------------------------------------
Timeout API
void attach (void(*fptr)(void), float t)
Attach a function to be called by the Ticker , specifiying the interval in seconds.
void attach_us (void(*fptr)(void), timestamp_t t)
Attach a function to be called by the Ticker , specifiying the interval in micro-seconds.
void detach ()
Detach the function.
--------------------------------------------------------------------------
Ticker API
void attach (void(*fptr)(void), float t)
Attach a function to be called by the Ticker , specifiying the interval in seconds.
void attach_us (void(*fptr)(void), timestamp_t t)
Attach a function to be called by the Ticker , specifiying the interval in micro-seconds.
void detach ()
Detach the function.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
