I got some nifty sensors from Ada Fruit a few weeks ago to do some demos for my Intro to PComp class at 3rd Ward. They were all pretty easy to get up and running.
The one sensor I didn’t really get a chance to test out was the IR Reciever. I’ve had a bunch of Apple remotes lying around and since pretty much anyone with a Mac has one of the remotes I thought it would be a good universal control. In this case, I would have a combination of buttons activate a “lock”, thus the creation of a IR remote combo lock.
I found a sketch on the Arduino site that analyzed the various button press signals from any remote. With this I ended up with at waveform graph for each button. The documentation for this ended at this point so I emailed the creator to try to find out what to do with this info. He ended up referring me to another thread.
I ended up deciding to switch gears back to an IR distance sensor Theremin I had previously started. It was a very easy setup. I found a speaker someone had thrown away and hooked it up to the digital PWM pin as an output and then to the ground. The IR distance sensor plugs into the 5V(red) and ground(black) and then an analog input(white).
int sensorPin = 0;
int speakerPin = 9;
int val;
int distance;
int tones[] = { 1915, 1805, 1706, 1608, 1519, 1432, 1859, 1275, 1205, 1136, 1072, 1014, 956, 903, 852, 804, 759 };
void setup() {
pinMode(sensorPin, INPUT);
pinMode(speakerPin, OUTPUT);
pinMode(speakerPinB, OUTPUT);
Serial.begin(9600);
}
void loop() {
distance = int(analogRead(sensorPin));
val = map(distance, 40, 640, 0, 12);
Serial.print(distance);
Serial.print(",");
Serial.println(val);
digitalWrite(speakerPin, HIGH);
delayMicroseconds(tones[val]);
digitalWrite(speakerPin, LOW);
delayMicroseconds(tones[val]);
}











