LinkIt ONE Tutorial - Light Sensor


What We’re Doing
It’s time to know about new sensors that could make our projects even more interesting. A photoresistor (light dependent resistor or photocell) is a light sensor which varies its resistance value based on the intensity of the ambient light. A buzzer is a electro-acoustic device used to generate standard tone when it is connected to the power supply. Lets use both these components in our experiments.
Things you need
  • LinkIt One x 1
  • Break board x 1
  • Resistors 10kΩ,1kΩ,330Ω x 1
  • Buzzer x 1
  • Photoresistor x 1
  • Transistor(2N3904)x 1
Please click on the button below to download the code for the kit:
You can unzip the file to the Examples folder of your Arduino IDE.
To access the demo code open:
File -> Examples -> Starter Kit for LinkIt -> Basic -> L8_Light_Control_Buzzer
const int pinBuz = 3; // pin define of LED const int pinLight = A0; // pin define of Light Sensor void setup() { pinMode(pinBuz, OUTPUT); pinMode(pinLight, INPUT); } void loop() { int value = analogRead(pinLight); value = map(value, 0, 1023, 255, 0); analogWrite(pinBuz, value); delay(100); }
  • Photosensitive does not work ?
    • Photoresistor lead’s wire spacing is not standard. It is easy to short the leads. Carefully check.
  • No Sound?
    • Buzzer leads are very short. Carefully check if they are properly inserted in the breadboard.
Making it better
Lets control the tone of the buzzer further using the photoresistor. Different tones can be generated if you vary the light intensity that falls on the photo resistor. Upload the following code and observe the difference.
To access the demo code open:
File -> Examples -> Starter Kit for LinkIt -> Extend_Lesson –> L8_Buzzer_Music
More ideas
We can make more interesting applications using photocell. Try making a light-sensitive Christmas gift.

Help us make it better

Thank you for choosing Seeed. A couple of months ago we initiated a project to improve our documentation system. What you are looking at now is the first edition of the new documentation system. Comparing to the old one, here is the progresses that we made:
  • Replaced the old documentation system with a new one that was developed from Mkdocs, a more widely used and cooler tool to develop documentation system.
  • Integrated the documentation system with our official website, now you can go to Bazaar and other section like Forum and Community more conveniently.
  • Reviewed and rewrote documents for hundreds of products for the system’s first edition, and will continue migrate documents from old wiki to the new one.
An easy-to-use instruction is as important as the product itself. We are expecting this new system will improve your experience when using Seeed’s products. However since this is the first edition, there are still many things need to improve, if you have any suggestions or findings, you are most welcome to submit the amended version as our contributor or give us suggestions in the survey below, Please don’t forget to leave your email address so that we can reply.
Happy hacking