Alert icon
We're changing our privacy policy. This stuff matters.  Learn more  Dismiss

Arduino + LED's + Photocell

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
218 views
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Mar 12, 2011

Simple Arduino circuit that flashes LED's based on the input from a photocell.

Code Below:


const int analogIN = A0; //Defines the Analog pin for IN

int sensorValue = 0; //Value read from the light sensor
int outputValue = 0; //output to the analog out
const int AnalogOUT1 = 3;
const int AnalogOUT2 = 5;
const int AnalogOUT3 = 6; //defining physical pins 3,5,6,9, and 10 as AnalogOUT1-5
const int AnalogOUT4 = 9;
const int AnalogOUT5 = 10;

void setup() { Serial.begin(9600); pinMode(AnalogOUT1, OUTPUT);
pinMode(AnalogOUT2, OUTPUT);
pinMode(AnalogOUT3, OUTPUT); // Set the Analog pins to be output
pinMode(AnalogOUT4, OUTPUT);
pinMode(AnalogOUT5, OUTPUT);
}



void loop() {
sensorValue = analogRead(analogIN); // read the analog in value: outputValue = map(sensorValue, 0, 3000, 0, 5000); // map range of sensor and output, change for new ratio!!!
analogWrite(AnalogOUT1, outputValue);
analogWrite(AnalogOUT2, outputValue);
analogWrite(AnalogOUT3, outputValue); // change the analog out value
analogWrite(AnalogOUT4, outputValue);
analogWrite(AnalogOUT5, outputValue); Serial.print("sensor = " ); // print the results to the serial monitor Serial.print(sensorValue); Serial.print("\t output = "); Serial.println(outputValue); delay(10); // 10ms delay
}

  • likes, 0 dislikes

Link to this comment:

Share to:
see all

All Comments (0)

Sign In or Sign Up now to post a comment!
Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more