![](/media/cache/profiles/cfee7edeb341158110ece5fba9440f58.jpg.50x50_q85.jpg)
this is a small prototype for color sensor, which can detect three colors... this was made by using an LDR,1.5 K resistor and the wiz wiki 7500 board
Fork of ADC_test by
the things you need for this are wiznet board or any other micro controller can do it when you understand the logic i have applied here.An LDR and one resistor for your reference i have used 1.5K resistor in my work.
connect the LDR and resistor in series in between the 3.3V and GND of the board.take outpt from the point where LDR and resistor met.
it's just an voltage divider circuit depends on the color you subject to LDR the resistance of LDR will vary and the volatge also does the same.
then feed the output on the adc pin of micro controller, then you will get various values for various colors. the adc which i have used is 12 bit one that's why it's having 4096 count. you have to change the values in the program according to your adc count.
sorry for my bad english.........
main.cpp
- Committer:
- shia
- Date:
- 2016-01-18
- Revision:
- 1:c88c8173b9b2
- Parent:
- 0:a2562dfbf543
File content as of revision 1:c88c8173b9b2:
#include "mbed.h" AnalogIn adc(A0); DigitalOut myled1(LED1); DigitalOut myled2(LED2); DigitalOut myled3(LED3); int meas; int main() { printf("\n GSAS Micro Systems \r\n"); wait(0.1f); while(1) { meas = adc.read_u16(); printf("meas is %d\r\n", meas); if(meas<1000){ myled1 = 1; myled2 = 1; myled3 = 0; wait(0.5);} else myled3 = 1; if(meas>1000){ if(meas<1100){ myled1 = 0; myled2 = 1; myled3 = 1; wait(0.5);} else myled1 = 1;} if(meas>1100){ myled1 = 1; myled2 = 0; myled3 = 1; wait(0.5);} else myled2 = 1; wait(0.3); } }