IOP / Mbed 2 deprecated CDS_HelloWorld_WIZwiki-W7500

Dependencies:   mbed

Fork of CDS_HelloWorld_WIZwiki-W7500 by IOP WIZnet

main.cpp

Committer:
IOP
Date:
2015-07-24
Revision:
4:9866fbe66750
Parent:
3:b4272b24707b
Child:
5:07cf6e09cd27

File content as of revision 4:9866fbe66750:

#include "mbed.h"
 
DigitalOut myled_R(D9);     // LED_RED on easy module shield
DigitalOut myled_G(D10);     // LED_GREEN on easy module shield  
DigitalOut myled_B(D11);    // LED_BLUE on easy module shield
AnalogIn CDS(A1);            // Analog Input Pin A1
 
int main() {
    printf("Hello WizWIki-W7500!\n\r");
    printf("===========================================\n\r");
    
    int CDS_data = 0;
    double CDS_vol = 0;
    
    while(1) {
        CDS_data = CDS.read()*1000;
        CDS_vol = CDS.read()*3.3;
        
        //CDS Seneor ADC Low Data
        printf("CDS Data : %3d\r\n",CDS_data);      
        //CDS Sensor Voltage data
        printf("CDS Voltage : %3.3lfV\r\n",CDS_vol);
        printf("===========================================\n\r");
        
        wait(1);     
        //Status is dark and RED LED ON, the others OFF
        if(CDS_data < 500){
            myled_R = 1;
            myled_G = 0;
            myled_B = 0;
        }
        //Status is bright and BLUE LED ON, the others OFF
        else  {
            myled_R = 0;
            myled_G = 0;
            myled_B = 1;
        }
    }
}