As a starting point, you may detect objects upto 6 inches apart. You will need to connect everything according to the following schematic:
[See Image attached]
Example Arduino Code:
int Alert = 2; // Connect Alert!! LED to Digital pin 2
int infraRed = A0; // Infra Red Receiver (Photo Diode) to Analog Pin A0
int x = analogRead(infraRed);
if(x > 1020) // Since Arduino has 10-bit ADC,
// the range of input from IR Rx (Photo Diode) would be between 0 - 1024.
// you will find that when an obstacle is detected,
// the value in Serial Monitor is just close to 1024 (i.e., HIGH).
// It works when both IR Tx and IR Rx (Photo Diode) are upto 6 inches apart.
Note that in the schematic, IR Receiver is not connected like a normal LED with cathode to Ground.
Since it is actually a transistor with 'open' base to detect light.
The Alert!! LED will not Light up until there is an obstruction in between the InfraRed Tx and Rx (placed 5 to 6 inches apart).
- Schematic on mini BB_bb.jpg (203.49 KiB) Viewed 3031 times
Who is online
Users browsing this forum: No registered users and 1 guest