Introduction: IR Sensor Button
This example shows a infrared sensor button with an integrated light. If you touch the surface then the button lights red. Touch the surface again, then the light turns off.
The first image is a design example.
Step 1: Circuit
To change the intensity of the Phototransistor (T1) use an another resistor for R4.
Step 2: Parts List
D1 IR LD271
D2 LED 500 red
K1 male connector 4pins
R1 10KOhm
R2,R3 100 Ohm
R4 510KOhm
T1 SFH300FA
T2 BC547A
Attachments
Step 3: Arduino Sketch
The Arduino Code is very simple:
#define ACTIVATE_VALUE 750 // Change this value for an another distance
#define PRESS_THRESHOLD 250
int SENSOR_VALUE;
byte ON_OFF = 0;
void setup() {
Serial.begin(9600);
pinMode(2, OUTPUT);
pinMode(A0, INPUT);
}
void loop() {
SENSOR_VALUE = analogRead(A0);
Serial.println(SENSOR_VALUE);
if (SENSOR_VALUE > ACTIVATE_VALUE) {
digitalWrite(2, ON_OFF = !ON_OFF);
delay(PRESS_THRESHOLD);
}
delay(100);
}
Attachments
Step 4: Example
With a sheet of sandpaper I have made the surface of the acrylglas diffuse.
Youtube: www.youtube.com/watch?v=L9-gg7UPTqw

Participated in the
Sensors Contest
3 Comments
8 years ago on Introduction
Cool!
9 years ago
nice idea, it's simple to replace the arduino with one transistor
9 years ago
I like it it's nice and easy