This is an exercise to blink an LED with a switch. Users can learn how to put digital input into the WIZwiki board with a switch. Users can learn how to get digital output from a specified pin in the WIZwiki board.
- USB cable
- Jumper wire
- Resistor (330 Ohm)
- Test S/W : In order to check serial data, terminal program is required on the PC. Tera Term is used in this exercise.
This is the circuit for this example.
The LED for this example is placed on the WIZwiki board and it is shown in the red box in the cicuit below.
Below are the example codes. Delete the default code and copy/paste the codes below and compile.
DigitalOut myled(LED1) part configures LED1 as an output mode. DigitalIn mybutton(D6) part configures D6 pin as an input mode.
When pushing a button, the LED turns on. When 3.3V drives to D6 pin, mybutton will be recognized as “1”, myled becomes “0”. When myled becomes “0”, then the LED1 on the WIZwiki board turns on.
When you release the button, the LED turns off.
To learn Class and API like the DigitalOut and DigitalIn parts of the above example code, refer to the mbed Handbook page. 🌎https://developer.mbed.org/handbook/Homepage