IT Tralee Life Long Learning 2020 Instrumentation, Monitoring and Control Module Laboratory Session

Dependencies:   mbed C12832

Committer:
alejandromontes
Date:
Mon Jul 27 19:58:10 2020 +0000
Revision:
0:0d968e787929
Alejandro Montes Instrumentation Monitoring and Control LAB

Who changed what in which revision?

UserRevisionLine numberNew contents of line
alejandromontes 0:0d968e787929 1 #include "mbed.h"
alejandromontes 0:0d968e787929 2 #include "C12832.h"
alejandromontes 0:0d968e787929 3
alejandromontes 0:0d968e787929 4 InterruptIn joystickcenter(p14);
alejandromontes 0:0d968e787929 5 InterruptIn button(p9);
alejandromontes 0:0d968e787929 6 DigitalOut led(LED1);
alejandromontes 0:0d968e787929 7 DigitalOut flash(LED4);
alejandromontes 0:0d968e787929 8 C12832 lcd(p5, p7, p6, p8, p11);
alejandromontes 0:0d968e787929 9 int x;
alejandromontes 0:0d968e787929 10
alejandromontes 0:0d968e787929 11 void flip() {
alejandromontes 0:0d968e787929 12 x=1;
alejandromontes 0:0d968e787929 13 led = !led; // toggles the led when the joystick button is pressed.
alejandromontes 0:0d968e787929 14 }
alejandromontes 0:0d968e787929 15
alejandromontes 0:0d968e787929 16 int main() {
alejandromontes 0:0d968e787929 17 joystickcenter.rise(&flip); // attach the function address to the rising edge
alejandromontes 0:0d968e787929 18 button.mode(PullUp); // With this, no external pullup resistor needed
alejandromontes 0:0d968e787929 19 button.rise(&flip); // attach the function address to the rising edge
alejandromontes 0:0d968e787929 20 while(1) { // wait around, interrupts will interrupt this!
alejandromontes 0:0d968e787929 21 flash = !flash; // turns LED4 on if off, off if on
alejandromontes 0:0d968e787929 22 wait(0.25); // the instruction to wait for a quarter-second
alejandromontes 0:0d968e787929 23 if(x==1){ //Check if the variable has been set and if so displays a message on the LCD
alejandromontes 0:0d968e787929 24 lcd.locate(0,10);
alejandromontes 0:0d968e787929 25 lcd.printf("Varialble SET!");
alejandromontes 0:0d968e787929 26 wait(0.5);
alejandromontes 0:0d968e787929 27 lcd.cls(); //Clears out the LCD
alejandromontes 0:0d968e787929 28 x=0; //Set the variable back to 0
alejandromontes 0:0d968e787929 29 }
alejandromontes 0:0d968e787929 30 }
alejandromontes 0:0d968e787929 31 }