element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Crazy Arduino Automations
  • Challenges & Projects
  • Project14
  • Crazy Arduino Automations
  • More
  • Cancel
Crazy Arduino Automations
Crazy Arduino Automations Blog The WRONGCO Hamper Helper – blog 4 – photo detection system test with Arduino at the helm
  • Blog
  • Forum
  • Documents
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Crazy Arduino Automations to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: robogary
  • Date Created: 13 May 2023 4:23 PM Date Created
  • Views 1135 views
  • Likes 8 likes
  • Comments 2 comments
  • Arduino Day Challenge
  • crazyarduinoautomationch
  • robogary
Related
Recommended

The WRONGCO Hamper Helper – blog 4 – photo detection system test with Arduino at the helm

robogary
robogary
13 May 2023

Blog 4 is takes all the lessons learned from the 1st 3 blogs, assembles the prototype of the photo-eye detection system, providing engineering test and calibration validation while operating from the Arduino.

Please reference for background blogs:

The WRONGCO Hamper Helper – blog 3 – photo "electric eye" detection calibration, and down a COB LED rabbit hole

The WRONGCO Hamper Helper–blog 2-Intro to Optical sensors from a Dummy

The WRONGCO Hamper Helper - experiment 1 dirty clothes pile height detection - not so good

The Arduino test program:

  • Reads each phototransistor to sample the voltage drop at ambient light intensity
  • Individually turns on each COB LED “transmitter assembly”
  • Reads the corresponding phototransistor “receiver” value when COB LED is on
  • The cycling is slow enough to allow for manual confirmation of the phototransistor voltages with a DVM

image

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

image

// ---------------------------------------------------------------------------
//
// This is a test program for the Hamper Helper "Electric Eye" 
// which detects and alerts if clothes are piled above the top of the hamper.
// This program fires the COB light source & reads the voltage drop across the 
// phototransistor mounted directly across from it. 
// Low light conditions, the phototransistor is high impedance, reading a voltage drop of approximately 5V.
// If the phototransistor sees the COB LED light, the phototransistor conducts more, with a lower voltage drop. 
// The measured voltage drop of the phototransistor hit with the COB LED beam is about 4V. 
// The code will set a "beam seen" flag if the beam is detected. If the beam isnt seen when the COB LED is lit, 
// it assumed clothes are blocking the light beam.   
// This simple code tests the beam COB LED transmitter and phototransistor detector.
// ---------------------------------------------------------------------------


int LongitudePhotoEyeValue;
int LatitudePhotoEyeValue;
int LongitudeSeeBeam;
int LatitudeSeeBeam;
float LatitudePhotoEyeVolts;
float LongitudePhotoEyeVolts;


void setup() {

pinMode(A2, INPUT); // Latitude phototransistor voltage drop 5V = no light (1023), 4V sees beam (900)
pinMode(A3, INPUT); // Longitude phototransistor voltage drop 5V = no light, (1023), 4V sees beam (900)

pinMode(2, OUTPUT); // Driver for Latitude PhotoElectric Eye COBLED
pinMode(3, OUTPUT); //Driver for Longitude PhotoElectric Eye COBLED
//pinMode(5, OUTPUT); // turn on Hamper Full BUZZER
//pinMode(6, OUTPUT); // turn on Hamper Full Flashing LED assembly
//pinMode(7, OUTPUT); // Power atomizer
//pinMode(8, OUTPUT); // start atomizer

delay(1000);//a little power up time for Buck PSs to settle
Serial.begin(9600);

//Arduino's PWM frequency at about 500Hz, analogWrite(255) requests a 100% duty cycle (always on), 
//and analogWrite(127) is a 50% duty cycle (on half the time) for example.
}



void loop() 
{
  delay(5000);  // how often to cycle test to give time to manually verify readings.

// check Latitude direction for eye Beam 
digitalWrite(2, HIGH); // Latitude turn on COB LED
delay(500); 
LatitudePhotoEyeValue=analogRead(A2); 
LatitudePhotoEyeVolts=(LatitudePhotoEyeValue)*5.0/1023.0;
delay(50);
if (LatitudePhotoEyeValue<920)
  { LatitudeSeeBeam = HIGH;}
  else   { LatitudeSeeBeam = LOW;}
digitalWrite(2, LOW); // Latitude turn off COB LED  
Serial.print( "LatiitudePhotoEyeValueLIT=");
Serial.println( LatitudePhotoEyeValue);
Serial.print( "LatiitudePhotoEyeVoltsWhenLIT=");
Serial.println( LatitudePhotoEyeVolts, DEC);
Serial.println(" ");
delay(1000); // give time for DVM to display reading
digitalWrite(2, LOW); // Latitude turn off COB LED 



// check Longitude direction for eye Beam 
//digitalWrite(2, HIGH); // Latitude turn on COB LED
delay(500); 
LatitudePhotoEyeValue=analogRead(A2); 
delay(50);
//if (LatitudePhotoEyeValue<920)
//  { LatitudeSeeBeam = HIGH;}
//  else   { LatitudeSeeBeam = LOW;}
//digitalWrite(2, LOW); // Latitude turn off COB LED  
Serial.print( "LatiitudePhotoEyeValue_AMB=");
Serial.println( LatitudePhotoEyeValue);
Serial.println(" ");
  
// check Longitude direction for eye Beam 
digitalWrite(3, HIGH); // Longitude turn on COB LED
delay(500); 
LongitudePhotoEyeValue=analogRead(A3); 
LongitudePhotoEyeVolts=(LongitudePhotoEyeValue)*5.0/1023.0;
delay(50);
if (LongitudePhotoEyeValue<920)
  { LongitudeSeeBeam = HIGH;}
  else   { LongitudeSeeBeam = LOW;}
Serial.print( "LongitudePhotoEyeValue=");
Serial.println( LongitudePhotoEyeValue);  
Serial.print( "LongitudePhotoEyeVolts=");
Serial.println( LongitudePhotoEyeVolts, DEC);  
Serial.println(" ");  
delay(1000); // give time for DVM to display reading
digitalWrite(3, LOW); // Longitude turn off COB LED



//test ambient value
LongitudePhotoEyeValue=analogRead(A3); 
delay(50);
Serial.print( "LongitudePhotoEyeValue_AMBIENT=");
Serial.println( LongitudePhotoEyeValue);  
Serial.println(" ");
 
}

 

  • Sign in to reply

Top Comments

  • robogary
    robogary over 2 years ago +1
    superbly submitted. Insightful test code.
  • mp2100
    mp2100 over 2 years ago

    Superb and insightful, yes good so far.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • robogary
    robogary over 2 years ago

    superbly submitted. Insightful test code. 

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube