RasPi Bird-O-Matic/ Bird Photo Booth

After testing and debugging the sketch on an Arduino UNO, I modified it to run on an ATtiny84.

#include    // LCD Display Driver for 16x2 LCD with shift register
LiquidCrystal595 lcd( 2, 5, 4); // AtTiny84 (Data, Latch, Clock) - pin order from left to right on 595LCD is GND, +5, Clock, Latch, Data.
int pd=1;                         // Photodiode to digital pin 2
int oc=0;                    // Pin that goes to optocoupler
 int senRead=3;                 // Readings from sensor to Analog Pin 3
 int limit=850;                 // Threshold to trigger relais if an object is detected
 int pot=6;´
 void setup()
 {
 lcd.begin(16,2);              //
 lcd.setCursor(2,0);           //
 lcd.print("ATtiny84 IR -");   //
 lcd.setCursor(1,1);           //
 lcd.print("Distance Sensor"); //
 delay(3000);                  //
 lcd.clear();                  //
 pinMode(pd,OUTPUT);           //
 pinMode(oc,OUTPUT);           //
 digitalWrite(pd,HIGH);        // Supply 5 volts to photodiode
 digitalWrite(oc,LOW);         // Set the Output in OFF mode (initial condition)
 //Serial.begin(9600);         // Setting serial monitor at a default baund rate of 9600
 }
 void loop()
 {
 int val=analogRead(senRead);  //variable to store values from the photodiode
 limit = analogRead(pot);
 lcd.setCursor(0,0);
 lcd.print("Distance:");
 lcd.setCursor(10,0);
 lcd.print(val,1);             // prints the values from the sensor in serial monitor
 lcd.setCursor(14,0);
 lcd.print("AU");
 lcd.setCursor(1,1);
 lcd.print("Threshold: ");     //
 lcd.print(limit);
 if(val <= limit)              // If obstacle is nearer than the Threshold range
 {
 digitalWrite(oc,HIGH);        // Output will be in ON state
 lcd.setCursor(1,1);
 lcd.print("Object detected!");
 delay(5000);
 lcd.clear();
 }
 else if(val > limit)          // If obstacle is not in threshold range
 {
 digitalWrite(oc,LOW);      // Output will be in OFF state
 delay(50);
 }
 }

Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments