Toggles an LED whenever a digital joystick input goes high

Dependencies:   mbed

main.cpp

Committer:
mb4899
Date:
2015-02-17
Revision:
0:188b8ea8f365

File content as of revision 0:188b8ea8f365:

#include "mbed.h"

InterruptIn joystick_Reset(p14); // Configure InterruptIn object with p14, which corresponds to joystick reset function
DigitalOut myLED(LED4); // Has to be LED1-4, not a pin

void toggle(void);

int main()
{
    joystick_Reset.rise(&toggle); // Attach the address of the toggle to the rising edge
}

void toggle()
{
    myLED=!myLED;
}