This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
draft:laser_light_sensor [2015/06/26 01:40] – dp | project:laser_light_sensor [2015/07/14 13:17] (current) – [Light diffuser] dp | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Laser/light sensor ====== | ====== Laser/light sensor ====== | ||
- | Aim of the project is to build lightweight laser/light sensor that can be mounted on quadcopter and used for gaming purposes. Sensor reads environmental light level via LDR, and sets the threshold below it. Any significant change in the light level will trigger the LED-s. Sensor will be used for the Dronosphere workshop and performance.\\ | + | Aim of the project is to build lightweight laser/light sensor that can be mounted on quadcopter and used for gaming purposes. Sensor reads environmental light level via LDR, and sets the threshold below it. Any significant change in the light level will trigger the LED-s. Sensor will be used for the [[http:// |
- | {{:draft: | + | {{: |
- | {{:draft: | + | {{: |
==== List of components ==== | ==== List of components ==== | ||
* 1 Arduino Uno (or Duemilanove with an ATmega328) | * 1 Arduino Uno (or Duemilanove with an ATmega328) | ||
Line 17: | Line 17: | ||
===== Arduino ===== | ===== Arduino ===== | ||
- | It's recommended to test the circuit on Arduino first. You will have serial monitor available and you will be able to read LDR readings | + | It's recommended to test the circuit on Arduino first. You will have serial monitor available and will be able to see LDR values |
==== Arduino schematic ==== | ==== Arduino schematic ==== | ||
- | {{:draft: | + | {{: |
==== Arduino code ==== | ==== Arduino code ==== | ||
Line 57: | Line 57: | ||
delay(50); | delay(50); | ||
} | } | ||
- | delay(3000); | + | delay(1000); |
threshold = analogRead(LDR) - sensitivity; | threshold = analogRead(LDR) - sensitivity; | ||
+ | delay(1000); | ||
} | } | ||
else | else | ||
Line 68: | Line 69: | ||
- | ===== ATtiny (shrinkifying | + | ===== ATtiny (shrinking the sensor) ===== |
- | Now that we have tested everything, we can go on and move it to ATtiny microcontroller (tested | + | Now that we have tested everything, we can port it to ATtiny microcontroller (tested |
==== Programming an ATtiny with Arduino ==== | ==== Programming an ATtiny with Arduino ==== | ||
+ | Follow this instructions: | ||
* http:// | * http:// | ||
- | * http:// | + | |
+ | {{:arduino_attiny.png?nolink|}} | ||
+ | |||
+ | ==== Connect LDR, LED and power ==== | ||
+ | {{: | ||
==== ATTiny code ==== | ==== ATTiny code ==== | ||
<file c laser_light_sensor_ATtiny.ino> | <file c laser_light_sensor_ATtiny.ino> | ||
- | #define LDR A1 // analog pin to which LDR is connected | + | #define LDR A1 // analog pin to which LDR is connected |
- | int LDRValue = 0; | + | #define LED 1 // pin to which LED is connected |
- | #define LED 1 // LED pin | + | const int sensitivity = 40; // setting the light sensitivity |
- | int light_sensitivity; // sensitivity | + | |
- | float voltage; | + | int LDRValue = 0; |
+ | int threshold; // light sensitivity | ||
void setup() | void setup() | ||
{ | { | ||
- | pinMode(LED, | + | pinMode(LED, |
- | | + | |
} | } | ||
void loop() | void loop() | ||
{ | { | ||
- | LDRValue = analogRead(LDR); | + | LDRValue = analogRead(LDR); |
- | if (LDRValue < light_sensitivity) | + | |
- | { | + | if (LDRValue <= threshold) // if the LDR reading is lower than the threshold |
- | digitalWrite(LED, | + | { |
- | delay(3000); | + | |
- | digitalWrite(LED, | + | |
- | delay(1000); | + | delay(50); |
+ | digitalWrite(LED, | ||
+ | delay(50); | ||
+ | } | ||
+ | delay(1000); | ||
+ | threshold = analogRead(LDR) - sensitivity; | ||
+ | delay(1000); | ||
} | } | ||
else | else | ||
Line 106: | Line 119: | ||
} | } | ||
</ | </ | ||
- | ===== Putting | + | ===== Putting |
==== Stripboard ==== | ==== Stripboard ==== | ||
+ | Cut the these lines on the stripboard (this is underside view).\\ | ||
+ | {{: | ||
+ | |||
+ | ... and soldier all other components\\ | ||
+ | {{: | ||
==== Light diffuser ==== | ==== Light diffuser ==== | ||
- | Cover the LDRs with semi-transparent material to act as light diffuser. Doing this will make sensor sensitive over bigger area. Also leave enough space between LDRs and diffuser for light to spread. You can use ping pong ball for this. | + | Cover the LDRs with semi-transparent material to act as light diffuser. Doing this will make sensor sensitive over bigger area. Also leave enough space between LDRs and diffuser for light to spread. You can use ping pong ball, or ball from vending machine. |
===== Tips ===== | ===== Tips ===== |