run with easy module shield

Dependencies:   mbed

Fork of CDS_HelloWorld_WIZwiki-W7500 by IOP WIZnet

Committer:
IOP
Date:
Wed Feb 03 06:39:25 2016 +0000
Revision:
7:17a6ae52f531
Parent:
5:07cf6e09cd27
code changed

Who changed what in which revision?

UserRevisionLine numberNew contents of line
joon874 0:fe7126797254 1 #include "mbed.h"
joon874 0:fe7126797254 2
IOP 5:07cf6e09cd27 3 DigitalOut myled_R(LED_RED); // LED_RED on WIZwiki-W7500
IOP 5:07cf6e09cd27 4 DigitalOut myled_B(LED_BLUE); // LED_BLUE on WIZwiki-W7500
IOP 7:17a6ae52f531 5
IOP 7:17a6ae52f531 6 AnalogIn CDS(A0); // Analog Input Pin A0
joon874 0:fe7126797254 7
joon874 0:fe7126797254 8 int main() {
IOP 5:07cf6e09cd27 9 printf("Hello WizWIki-W7500!\r\n");
IOP 5:07cf6e09cd27 10 printf("==============================\r\n");
joon874 0:fe7126797254 11
joon874 0:fe7126797254 12 int CDS_data = 0;
joon874 0:fe7126797254 13 double CDS_vol = 0;
joon874 0:fe7126797254 14
joon874 0:fe7126797254 15 while(1) {
joon874 0:fe7126797254 16 CDS_data = CDS.read()*1000;
joon874 0:fe7126797254 17 CDS_vol = CDS.read()*3.3;
joon874 0:fe7126797254 18
joon874 0:fe7126797254 19 //CDS Seneor ADC Low Data
joon874 0:fe7126797254 20 printf("CDS Data : %3d\r\n",CDS_data);
joon874 0:fe7126797254 21 //CDS Sensor Voltage data
joon874 0:fe7126797254 22 printf("CDS Voltage : %3.3lfV\r\n",CDS_vol);
IOP 5:07cf6e09cd27 23 printf("===========================\r\n");
IOP 5:07cf6e09cd27 24 wait(1.0);
joon874 0:fe7126797254 25
IOP 7:17a6ae52f531 26 //Status is Dark and BLUE LED OFF, RED LED ON
IOP 7:17a6ae52f531 27 if(CDS_data > 500){
IOP 7:17a6ae52f531 28 myled_R = 0;
IOP 7:17a6ae52f531 29 myled_B = 1;
IOP 7:17a6ae52f531 30 }
IOP 7:17a6ae52f531 31 //Status is Bright and BLUE LED ON, RED LED OFF
IOP 7:17a6ae52f531 32 else {
IOP 4:9866fbe66750 33 myled_R = 1;
IOP 4:9866fbe66750 34 myled_B = 0;
joon874 0:fe7126797254 35 }
joon874 0:fe7126797254 36 }
joon874 0:fe7126797254 37 }