The Waving Hand

The motivation for this project was to play around with potentiometers and Servos with my son. But we needed support of my daughter: She was the one providing this superb hand, which my son and I made waving:

We just mounted the hand on a Servo and made it wave by playing around with a potentiometer.

Required Hardware

  • Arduino uno
  • 2 x LED
  • 2 x resistor 220 Ohm
  • 1 x potentiometer
  • 1 x Servo motor
  • 1 x capacitor

Circuit

Connecting the LEDs

Connect both LED’s cathode with a 220 Ohm resistor and GND.

Connect the Anode of the green LED with pin 2 and the anode of the yellow LED with pin 3.

Connecting the potentiometer

Connect the output pin of the potentiometer with Uno’s pin A0. One of the other pins with GND and the last one with 5V.

Connecting the Servo

Connect the GND pin of the Servo with Uno’s GND.

Use the input signal pin of the Servo with Uno’s pin 11 – a PWM pin.

Attention: I connected the Servos 5V pin with Uno’s 5V stabilizeing everything with the capacitor. I could do this, because I used a very small Servo. If you have a bigger Servos than I had, you really should use a battery in addition as power source for the Servo. Otherwise you can destroy your Uno.

Code

#include "Servo.h"


const int pinInPoti = A0;
const int pinOutServo = 11;
const int pinOutLEDgrun = 2;
const int pinOutLEDgelb = 3;

Servo myServo;

void setup() {
pinMode(pinInPoti,INPUT);
pinMode(pinOutLEDgrun,OUTPUT);
pinMode(pinOutLEDgelb,OUTPUT);

digitalWrite(pinOutLEDgrun, 0);
digitalWrite(pinOutLEDgelb, 0);

myServo.attach(pinOutServo);
myServo.write(0);

}

void loop() {
int gelesen = analogRead(pinInPoti);

if(gelesen < 5) {
digitalWrite(pinOutLEDgrun, 255);
} else {
digitalWrite(pinOutLEDgrun, 0);
}

if(gelesen > 1020) {
digitalWrite(pinOutLEDgelb, 255);
} else {
digitalWrite(pinOutLEDgelb, 0);
}

int schreiben = map(gelesen, 0, 1023, 0, 255);

myServo.write(schreiben);

delay(10);

}