tomasz_gurajek

Dependencies:   mbed C12832

Committer:
t00204088
Date:
Sat Aug 01 12:03:56 2020 +0000
Revision:
0:db463baf4187
tomasz_gurajek

Who changed what in which revision?

UserRevisionLine numberNew contents of line
t00204088 0:db463baf4187 1 #include "mbed.h"
t00204088 0:db463baf4187 2 #include "C12832.h"
t00204088 0:db463baf4187 3 int i;
t00204088 0:db463baf4187 4 C12832 lcd(p5,p6,p7,p8,p11);
t00204088 0:db463baf4187 5 InterruptIn joystickcenter(p14);
t00204088 0:db463baf4187 6 InterruptIn button(p9);
t00204088 0:db463baf4187 7 DigitalOut led(LED1);
t00204088 0:db463baf4187 8 DigitalOut flash(LED4);
t00204088 0:db463baf4187 9 void flip() {
t00204088 0:db463baf4187 10 led = !led; // toggles the led when the joystick button is pressed.
t00204088 0:db463baf4187 11 i = 1;
t00204088 0:db463baf4187 12 }
t00204088 0:db463baf4187 13 int main() {
t00204088 0:db463baf4187 14 joystickcenter.rise(&flip); // attach the function address to the rising edge
t00204088 0:db463baf4187 15 button.mode(PullUp); // With this, no external pullup resistor needed
t00204088 0:db463baf4187 16 button.rise(&flip); // attach the function address to the rising edge
t00204088 0:db463baf4187 17 while(1) { // wait around, interrupts will interrupt this!
t00204088 0:db463baf4187 18 if(i==1){
t00204088 0:db463baf4187 19 lcd.locate(0,0);
t00204088 0:db463baf4187 20 lcd.printf("Button pressed");
t00204088 0:db463baf4187 21 i=0;
t00204088 0:db463baf4187 22 }
t00204088 0:db463baf4187 23 flash = !flash; // turns LED4 on if off, off if on
t00204088 0:db463baf4187 24 wait(0.25); // the instruction to wait for a quarter-second
t00204088 0:db463baf4187 25 }
t00204088 0:db463baf4187 26 }
t00204088 0:db463baf4187 27