Andy Pomfret
/
UoY-32C-lab1-exercise
Template project for University of York ELE00032C Lab 1
main.cpp
- Committer:
- ajp109
- Date:
- 2020-09-29
- Revision:
- 2:f63cdb6f8a44
- Parent:
- 1:ee571cefc13b
- Child:
- 3:35d45c4dd5d2
File content as of revision 2:f63cdb6f8a44:
#include "mbed.h" int main() { // Initialise the digital pins D2 and D3 as outputs DigitalOut green(D2); DigitalOut red(D3); // Initialise the digital pins D4 and D5 as inputs with pullup resistors DigitalIn PB1(D4, PullUp); DigitalIn PB2(D5, PullUp); // Loop forever... while (true) { // Is PB1 being pressed? if (PB1 == false) { // Light the red LED, extinguish the green red = true; green = false; } // Is PB2 being pressed? if (PB2 == false) { // Extinguish the red LED, light the green red = false; green = true; } } }