Introduction: IR Sensor Button

Picture of IR Sensor Button
This is an easy way to make a infrared sensor button with the Arduino.
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

Picture of Circuit

To change the intensity of the Phototransistor (T1) use an another resistor for R4.

Step 2: Parts List

Picture of 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

Step 3: Arduino Sketch

Picture of 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);
}

Step 4: Example

Picture of Example
The case I have printed out on a 3D-Printer. The top plate is an 31x31x3mm Acryl-Glas. My button is 35x35x20mm big. The distance from the IR-Diod to the acrylplate is ~6mm.

With a sheet of sandpaper I have made the surface of the acrylglas diffuse.

Youtube: www.youtube.com/watch?v=L9-gg7UPTqw

Comments

Ploopy (author)2014-07-13

Cool!

Florizzz (author)2014-04-14

nice idea, it's simple to replace the arduino with one transistor

bigpaulie25 (author)2014-04-13

I like it it's nice and easy

About This Instructable

4,265views

38favorites

License:

More by ARPix:ATMEGA168 TQFP32 smd programmer shieldIR Sensor ButtonESM - ExternalSerialMonitor
Add instructable to: