Stupid Pet Trick #1

 

 

 

Overall Circuit:

 

11006457_940259445993973_5985161499375004758_n10394653_940259422660642_302201561848217451_n

 

Screen Shot 2015-03-02 at 11.15.26 PM

This is the output area.   11045389_940259365993981_5440655263303309765_n

This is the input, sensor area.

10410895_940259349327316_5473415224563346305_n

Push Sensor

11043000_940259409327310_2376737188354259269_n

When you push the basic force resisting sensor the LED will light up.

11029518_940259379327313_692260226126686727_n 11025139_940259392660645_2404396757996859653_n

This one will require you to push the push button and then as you place your finger closer to the photo cell the LED light will light up brighter.

The Code:

int sensePin = A0;
int ledPin = 9;
int ledPressPin= 8;
int pressPin = A2;
void setup () {

Serial.begin(9600);
pinMode (ledPin, OUTPUT);
pinMode (ledPressPin, OUTPUT);

}

void loop () {

//Serial.println (analogRead (sensePin));
Serial. println (analogRead (pressPin));

int valLight = analogRead (sensePin);
int valPress= analogRead (pressPin);

if (valPress > 0) digitalWrite(ledPressPin, HIGH);
else digitalWrite (ledPressPin, LOW);

valLight = constrain (valLight, 750, 900);
int ledLevel = map (valLight, 750, 900, 255, 0);

analogWrite (ledPin, ledLevel);

// if (val < 800) digitalWrite (ledPin, HIGH);
// else digitalWrite (ledPin, LOW);
}

One thought on “Stupid Pet Trick #1”

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>