Gabriella Levine

ongoing and past work

Project? for P-COMP

PhotoSensor Relay from gabriella levine on Vimeo.

A circuit for a photosensor that turns on, say, a light, or anything:

Read on for the code and photo up-close

int potPin = 0;//analog input pin that potentiometer attached to
int sensorValue = 0;//value read from analog sensor
int ledPin = 2; //LED and relay connected to digital pin 3
int led = 13;

//int valĀ  = 0; //input from heat / light / potentiometer into analog in pin 0

void setup(){
pinMode(ledPin, OUTPUT);

void loop(){
sensorValue= analogRead(potPin);//read value from the sensor

int brightness = map(sensorValue, 0,200,0,255);
if (sensorValue > 80)
digitalWrite(ledPin, HIGH);
else {
digitalWrite(ledPin, LOW);

//analogWrite(ledPin, brightness);
analogWrite(led, brightness);

Leave a Reply