Difference between revisions of "Lightseeking sensor Module"
(→Resource) |
(→Resource) |
||
Line 80: | Line 80: | ||
=='''Resource'''== | =='''Resource'''== | ||
− | [ | + | [http://wiki.sunfounder.cc/index.php?title=File:Lightseeking.zip Lightseeking][[File:ZIP.jpg]]<br> |
Revision as of 07:28, 20 March 2017
Contents
Introduction
The Lightseeking sensor Module can be used on a smart car robot for the experiment about light seeking. Since the resistance of a photoresistor decreases with stronger light, the car can be controlled to move based on the resistance change, that is, to seek for the light and follow it. Also the light intensity is indicated by the LED bar graph on the module.
Features
1.The Lightseeking sensor module consists of photoresistor, LED bar graph, 74HC595, and resistor and can detect light and reflect the intensity by the LEDs
2.The on and off of the LEDs is controlled by 74HC595; the photoresistor is connected to pin A
3.Standard double-sided printed circuit board, a 3-mm hole in the middle at one side for fixing
4.Working voltage: 5V
5.PCB size: 19 x 49 mm
Principle
The Lightseeking sensor module consists of photoresistor, LED bar graph, 74HC595, and resistor. In the experiment, we upload the code to the SunFounder Uno board in Arduino IDE. Then the photoresistor collects data of light intensity. Next, the data is sent to pin A0 of the Uno board, and the analog value at A0 read via the code is transferred to the 74HC595. At last, the value is indicated by the LED bar graph – the strong light, the more LEDs are on.
The schematic diagram
Pins and their function:
VCC:Positive supply voltage
GND:Ground
ST: time sequence input of storage register, connected to pin 12 of 74HC595. On the rising edge, data in the shift register moves into memory register
SH: Time sequence input of shift register, connected to pin 11 of 74HC595. On the rising edge, the data in shift register moves successively one bit, i.e. data in Q1 moves to Q2, and so forth.While on the falling edge, the data in shift register remain unchanged.
DS: Serial data input pin, connected to pin 14 of 74HC595
Q7’: Series output pin, connected to pin 9 of 74HC595
A: Analog output port of the photoresistor
Test code
//LightSeeking sensor /*By changing the intensity of the ambient light around the module, you can see different numbers of LEDs on the LED bar graph brighten accordingly.*/ //Email:support@sunfounder.com //Website:www.sunfounder.com //2016.07.02 const int latchPin = 12; //Pin connected to ST_CP of 74HC595 const int clockPin = 8; //Pin connected to SH_CP of 74HC595 const int dataPin = 11; // Pin connected to DS of 74HC595 const int photocellPin = A0; // A attach to A0 int photocell = 0; unsigned char code_val[] = {0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff}; //Display different numbers of LEDs void setup() { //set pins to output pinMode(latchPin,OUTPUT); pinMode(clockPin,OUTPUT); pinMode(dataPin ,OUTPUT); } void loop() { photocell = analogRead(photocellPin); //read the value of A0 int digital=map(photocell,0,1023,0,8); //Value read is divided into 8 equal portions digitalWrite(latchPin,LOW); shiftOut(dataPin,clockPin,MSBFIRST,code_val[digital]); /* return the latch pin high to signal chip that it no longer needs to listen for information */ digitalWrite(latchPin,HIGH); //pull the latchPin to save the data delay(1); }
Experimental phenomenon
You can see the number of the brightened LEDs on the module varies with changes of the ambient light intensity. Try to change the luminance (e.g. cover the photoresistor with your fingers) and see how will the bar graph change.
Note: Since there are 10 LEDs on the bar graph when only 8 digital outputs for the 74HC595, Q0 and Q1 are connected with two LEDs respectively. Therefore, when the light intensity is quite low, 4 or 2 LEDs will be on – that means when you see only 2 or 4 LEDs light up, in fact there are just 1 or 2 are on.