Use to WIZwiki-W7500. Sensing to CDS.
Dependencies: mbed
Fork of CDS_Sensor_WizWiki-W7500 by
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
CDS Sensor
https://developer.mbed.org/users/4180_1/notebook/using-a-photocell-to-determine-light-levels/
Wiring
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
Revision 1:19ab27910302, committed 2017-04-03
- Comitter:
- joon874
- Date:
- Mon Apr 03 00:24:25 2017 +0000
- Parent:
- 0:f6d98a2fee3b
- Commit message:
- Delete UART declaration.
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Jun 29 05:20:10 2015 +0000 +++ b/main.cpp Mon Apr 03 00:24:25 2017 +0000 @@ -3,23 +3,23 @@ DigitalOut myled(LED1); AnalogIn CDS(A0); -Serial pc(USBTX, USBRX); - int main() { - pc.baud(115200); - wait(0.5f); - pc.printf("Hello WizWIki-W7500!\n\r"); - pc.printf("===========================================\n\r"); + + wait(0.5); + 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 - pc.printf("CDS Data : %3d\r\n",CDS_data); + printf("CDS Data : %3d\r\n",CDS_data); //CDS Sensor Voltage data - pc.printf("CDS Voltage : %3.3lfV\r\n",CDS_vol); - pc.printf("===========================================\n\r"); + printf("CDS Voltage : %3.3lfV\r\n",CDS_vol); + printf("===========================================\n\r"); wait(1); //Status is bright. if(CDS_data < 600){