Digital Input simple example for WIZwiki-W7500 academy

Dependencies:   mbed

Fork of DigitalIn_HelloWorld_WIZwiki-W7500 by Lawrence Lee

Committer:
IOP
Date:
Wed Apr 19 01:04:19 2017 +0000
Revision:
18:4d702f3a0d0e
Parent:
17:2678f7976a04
code update;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
joon874 11:8955f95f2c2c 1 /* Digital Input Example Program */
joon874 11:8955f95f2c2c 2
mbed_official 0:aaf5a9d465fd 3 #include "mbed.h"
mbedAustin 5:fa65447e171b 4
IOP 18:4d702f3a0d0e 5 DigitalOut myled_R(LED1); // LED_RED on WIZwiki-W7500
IOP 17:2678f7976a04 6
IOP 18:4d702f3a0d0e 7 DigitalIn mysw(D10); // push switch
mbedAustin 5:fa65447e171b 8
mbedAustin 5:fa65447e171b 9 int main()
mbedAustin 5:fa65447e171b 10 {
IOP 13:f6b0834008ee 11 int sw_val;
mbedAustin 5:fa65447e171b 12
mbed_official 0:aaf5a9d465fd 13 while(1) {
IOP 13:f6b0834008ee 14
IOP 15:a2d578443c70 15 sw_val = mysw.read(); // Read Digital input value
IOP 13:f6b0834008ee 16
IOP 13:f6b0834008ee 17 printf("Digital Input value is %d \n\r", sw_val); // output Digital Input value
IOP 13:f6b0834008ee 18
IOP 16:15c653e11eae 19 if(sw_val == 1) // switch pushed, Red LED ON
IOP 17:2678f7976a04 20 {
IOP 17:2678f7976a04 21 myled_R = 0;
IOP 17:2678f7976a04 22 }
IOP 17:2678f7976a04 23 else
IOP 17:2678f7976a04 24 {
IOP 17:2678f7976a04 25 myled_R = 1; // the others, Red LED OFF
IOP 17:2678f7976a04 26 }
IOP 18:4d702f3a0d0e 27
IOP 15:a2d578443c70 28 wait(0.2);
mbed_official 0:aaf5a9d465fd 29 }
IOP 17:2678f7976a04 30 }