IR testing for Stupid Pet Trick

I started testing the ideas for the design of my stupid pet trick today, starting with the IR sensor.  I couldn’t find the one I was looking for at the computer store:

Instead I got these, the SEN 00241:

I’m not sure if they work as well, but I like that they are smaller and more discreet.  It seems like they will work with just a couple of holes in the front of the frame, instead of a big black brick being visible in the front.  Though, so far I can’t tell exactly what the best angle for sensing is.  See this video where I use my cell phone to dim an LED:

[yframe url=’http://www.youtube.com/watch?v=HODrfAnaZzU’%5D

Uh oh.  I got an email from Tom Igoe saying that this sensor only works for a few inches, while the other sensor will work for several feet, which is more of what I need.

Also, just had a thought on the train over here that the lights should ease on and off, so they don’t just flicker or all of a sudden appear if something jumps in front of the sensor.  But maybe that would be cool too.

Anyway, here are a couple of shots of the set up from today:

And a schematic of the circuit:

Also, here are some sketches I did while I was eating dinner for the figures.

Oh, and my Arduino code:

//initialize vars
const int ledPin = 11;
int aVal = 0;
int brite = 0;

//setup
void setup(){
Serial.begin(9600);
pinMode(ledPin, OUTPUT);

}

void loop(){
//read analog signal
aVal = analogRead(A0);
//divide 4
brite = map(aVal, 0, 150, 0, 255);
//write to led
analogWrite(ledPin, brite);
//write value
Serial.print(aVal);
Serial.print(” “);
Serial.println(brite);

}

Advertisements

Author: owen ribbit

poop

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