Introduction: Distance Controller for Height Adjustable Table

About: Creative powerhouse

This simple Arduino driven mod makes it possible to control your height adjustable table by using "the force". Simply hold your hand close to the controller to lower the table and a bit higher to raise it. It's an awesome way to get some magic into your everyday office life and I hope you will enjoy it.

Step 1: What You Need

1x Height adjustable table driven by motors.

1x Arduino UNO

1x HC-SR04 Distanse sensor

Jumper Wires

1x small breadboard (optional if you solder straight to the HC-SR04)

3D printed case

Step 2: Prepare the Table

When you disassemble the button controller on your height adjustable table you'll find three wires. Two are for up and down and the third is the trigger signal. Bring the cables together one by one to figure out which one is which. Since we will use the Arduino to generate the trigger signal we only need the up and down wires

1. Cut off the signal cable

2. Attach jumper wires to the up and down wires.

Step 3: 3D Print the Case

The case for the Arduino UNO prints in three parts. No support material is needed.

It's worth noting that it was modeled to fit a SainSmart Arduino UNO.

http://www.thingiverse.com/thing:891419

Step 4: Wiring

Connect the HC-SR04 and the wires like in the diagram.

I used USB to power the Arduino and this is what the 3d printed case was designed for but if you want you can of course use batteries instead.

Step 5: Code the Arduino

<p>/*<br>Force Table controler by Joakim Christoffersson
Based on HC-SR04 Ping distance sensor trollmaker.com/article3/arduino-and-hc-sr04-ultrasonic-sensor
 */</p><p>#define trigPin 13
#define echoPin 12
#define down 10
#define up 11</p><p>void setup() {
  Serial.begin (9600);
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  pinMode(down, OUTPUT);
  pinMode(up, OUTPUT);
  }</p><p>void loop() {
  int duration, distance;
  digitalWrite(trigPin, LOW);
  delayMicroseconds(10);
  digitalWrite(trigPin, HIGH);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;
  if (distance < 12) {
    // lower table
    Serial.println("DOWN");
    digitalWrite(down,HIGH);
     digitalWrite(up,LOW);
    }
    else if (distance > 12 && distance <50) {
    // raise table
    Serial.println("UP");
    digitalWrite(up,HIGH);
    digitalWrite(down,LOW);
    }
  else {
    digitalWrite(up,LOW);
    digitalWrite(down,LOW);
  }
  if (distance >= 300 || distance <= 0){
    Serial.println("Out of range");
  }
  else {
    Serial.print(distance);
    Serial.println(" cm");
  }
  delay(250);
}</p>
3D Printing Contest

Participated in the
3D Printing Contest