Skip navigation

Photocells
Just a quick post about hooking up a photocell to your arduino. This setup should work for other variable resistors (flex, force, etc).

Materials you’ll need:

  • Arduino Duemilanove
  • Photocell
  • 10K ohm resistor (brown, black, orange)
  •  

    Arduino Sketch

    /* 
     * Photocell Reading
     * -----------------
     *
     * Read an analog value from a photocell (variable resistor)
     * connected to analog pin 0.
     *
     * Created January 2010
     * Matt Wiechec
     *
     */
    
    int photocellPin = 0;     // select the input pin for the photocell
    int photocellVal;         // variable to store the analog valie from the cell
    
    void setup(void) {
      Serial.begin(9600);     // for debugging via the Serial Monitor
    }
    
    void loop(void) {
      photocellVal = analogRead(photocellPin);  
      
      Serial.print("Photocell Val: ");
      Serial.println(photocellVal);     // the raw analog reading
    
      delay(100);
    }
    

     

    Photocell Schematic

     

    Photocell Illustration

     

    Photos

    Advertisements

    Leave a Reply

    Fill in your details below or click an icon to log in:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out / Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out / Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out / Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out / Change )

    Connecting to %s

    %d bloggers like this: