Use to WIZwiki-W7500. Sensing to CDS.

Dependencies:   mbed

Fork of CDS_Sensor_WizWiki-W7500 by Scott Jeong

Prerequisite

This example is for controlling LED with CDS sensor. CDS or Photoresistor(or light-dependent resistor, LDR) is a light controlled variable resistor. The resister of a photoresistor decreases with increasing incident light intensity. CDS can be applied in light-sensitive detector circuits, and light- and dark-activated switching circuits.

  • WIZwiki-W7500 from WIZnet (Platform board and Ethernet I/F board)
  • CDS Sensor

Hardware Configuration

WIZwiki-W7500 Pin map

pin map

CDS Sensor

https://developer.mbed.org/users/4180_1/notebook/using-a-photocell-to-determine-light-levels/

Wiring

/media/uploads/joon874/cds_hw_wiring.png

ADC for CDS Sensor
6ch ADC on WIZwiki-W7500 is able to read from CDS Sensor are A0, A1, A2, A3,A4 and A5. 3 color LED on WIZwiki-W7500 is able to display the condition of CDS value are LED1, LED2 and LED3.


Software

Read CDS value

//Declaration ADC, GPIO Pin
DigitalOut myled(LED1);   // For Debug LED
AnalogIn CDS(A0);             //  ADC pin for CDS

CDS_data = CDS.read()*1000;  // .read() is function to read ADC value
CDS_vol = CDS.read()*3.3;        // *3.3 is for voltage range

Control LED with CDS value

 if(CDS_data < 600){
            myled = 1;             //  Light-activated
        }
        //Status is dark.
        else {
            myled = 0;            //  Dark-activated
        }

Caution

Basically WIZwiki-W7500 can be debug with USB cable. So User need to install mbed serial driver and set serial communication baud-rate 9600bps

Changes