Code from N.Outram lecture 23 Oct 2017

Committer:
martinsimpson
Date:
Tue Oct 24 14:01:04 2017 +0000
Revision:
0:24610a6f4e59
edited from N.Outram code lecture 23 Oct 2017

Who changed what in which revision?

UserRevisionLine numberNew contents of line
martinsimpson 0:24610a6f4e59 1 #include "mbed.h"
martinsimpson 0:24610a6f4e59 2 #include "swpol.hpp"
martinsimpson 0:24610a6f4e59 3
martinsimpson 0:24610a6f4e59 4 DigitalOut led1(LED1);
martinsimpson 0:24610a6f4e59 5
martinsimpson 0:24610a6f4e59 6 DigitalOut red_led(PE_15);
martinsimpson 0:24610a6f4e59 7 DigitalOut yellow_led(PB_10);
martinsimpson 0:24610a6f4e59 8 DigitalOut green_led(PB_11);
martinsimpson 0:24610a6f4e59 9 DigitalIn sw1(PE_12);
martinsimpson 0:24610a6f4e59 10 DigitalIn sw2(PE_14);
martinsimpson 0:24610a6f4e59 11
martinsimpson 0:24610a6f4e59 12 SWPoll switch1(sw1, red_led);
martinsimpson 0:24610a6f4e59 13 SWPoll switch2(sw2, green_led);
martinsimpson 0:24610a6f4e59 14
martinsimpson 0:24610a6f4e59 15 Timer t;
martinsimpson 0:24610a6f4e59 16
martinsimpson 0:24610a6f4e59 17 // main() runs in its own thread in the OS
martinsimpson 0:24610a6f4e59 18 int main() {
martinsimpson 0:24610a6f4e59 19 t.start();
martinsimpson 0:24610a6f4e59 20 while(1) {
martinsimpson 0:24610a6f4e59 21 if (t.read_ms() >= 500) {
martinsimpson 0:24610a6f4e59 22 yellow_led = !yellow_led;
martinsimpson 0:24610a6f4e59 23 t.reset();
martinsimpson 0:24610a6f4e59 24 }
martinsimpson 0:24610a6f4e59 25 switch1.poll();
martinsimpson 0:24610a6f4e59 26 switch2.poll();
martinsimpson 0:24610a6f4e59 27 };
martinsimpson 0:24610a6f4e59 28 }
martinsimpson 0:24610a6f4e59 29