Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
- Committer:
- kevinsullivan
- Date:
- 2020-07-27
- Revision:
- 3:2ff289a7fba1
- Parent:
- 1:6757d2875f4f
File content as of revision 3:2ff289a7fba1:
#include "mbed.h"
#include "C12832.h"
Serial pc(USBTX, USBRX); // tx, rx
InterruptIn joystickcenter(p14);
InterruptIn wire(p9);
DigitalOut led(LED1);
DigitalOut flash(LED4);
C12832 lcd(p5,p7,p6,p8,p11);
int i;
void flip()
{
led = !led; // toggles the led when the joystick button is pressed.
i=led;
}
int main()
{
joystickcenter.rise(&flip); // attach the function address to the rising edge
wire.mode(PullUp); // With this, no external pullup resistor needed
wire.rise(&flip); // attach the function address to the rising edge
while(1) { // wait around, interrupts will interrupt this!
flash = !flash; // turns LED4 on if off, off if on
wait(0.5); // the instruction to wait for half-second
if(i==0) {
lcd.locate(0,0);
lcd.printf("stand-by \n\r");
wait (0.1);
lcd.printf("LED1 = 0 \n\r");
wait (0.2);
}
if(i==1) {
lcd.locate(0,0);
lcd.printf("button press detected\n");
lcd.printf("LED = 1 \n\r");
wait (0.2);
}
}
}