The concept of controlling various servo motors through Arduino Uno board is introduced here with a fun project called ‘namaste robot.’ The robot turns its head by 180° and scans people in its range using an ultrasonic module. If it finds anyone nearby, it greets the person with ‘namaste’ with both hands pressing together, which is the traditional Indian way of wishing people. The robot can be used in offices, shopping centres, parks and party halls where it can greet and attract people.
Fig. 1 shows the author’s prototype of this robot. Please note that the ultrasonic module is mounted on the chest in author’s prototype, but during testing it was observed that if it is mounted on the eyes, it can scan a much larger area in its vicinity.
Circuit and working
Fig. 2 shows the circuit diagram of namaste robot. Servo motors M1 through M5 are used for elbows, shoulders and head movement. Arduino Uno board (Board1) uses ‘Servo.h’ library to drive these servo motors. The servo motor for the head keeps turning by 180° as already mentioned. The ultrasonic module HC-SR04 is mounted on the eyes to scan for any object in its vicinity. The ‘namaste’ audio message recording and playback is done using IC APR9301 (IC1).
Servo motors. These motors are extremely useful in robotics. These are small but extremely powerful for their size. A servo motor mainly comprises a DC motor, gear system, position sensor (which is mostly a potentiometer) and control electronics as shown in Fig. 3.
The DC motor is connected with a gear mechanism which provides feedback to a position sensor. The potentiometer allows the control circuitry to monitor the current angle of the servo motor. If the shaft is at the correct angle, the motor shuts off. If the circuit finds that the angle is not correct, it keeps the motor on until the angle is reached. A normal servo is used to get the angular motion up to 180°; it is incapable of turning any further due to a mechanical stop on its main output gear.
The control wire is used to communicate the turning angle. The angle is determined by the duration of a pulse that is applied to the control wire. This is called pulse-code modulation. Control wires for motors M1 through M5 are connected to pins 11, 9, 6, 10 and 5 of Board1, respectively.
The servo expects to see a 2-millisecond pulse every 20 milliseconds (0.02 seconds). The duration of the pulse determines how far the motor turns. A 1.5-millisecond pulse, for example, will make the motor turn to the frontal 90° position (often called the neutral position). If the pulse is shorter than 1.5 milliseconds, the motor’s shaft will turn lesser than 90°. If the pulse is longer than 1.5 milliseconds, the shaft will turn closer to 180° as shown in Fig. 4.
Ultrasonic transceiver module (HC-SR04). HC-SR04 ultrasonic transceiver module uses sonar to determine distance to an object, like bats or dolphins do. It offers excellent non-contact range detection of 2cm to 400cm with high accuracy and stable readings in an easy-to-use package. It comes complete with ultrasonic transmitter and receiver module. Fig. 5 shows the ultrasonic module.
To start the measurement, pin 2 (TRIG) of the module must receive a high pulse for at least 10 microseconds. This will initiate the module to transmit eight cycles of ultrasonic burst at 40kHz and wait for the reflected ultrasonic burst. When the sensor detects the reflected burst, it sets pin 3 (ECHO) to ‘high.’ The delay in receipt of the reflected pulse indicates the distance from the obstacle, which can be easily calculated as:
Distance (in centimetres) = T/58
T = Width of pulse at ECHO pin in microseconds
The TRIG and ECHO pins of the module are connected to pins 3 and 12 of Board1, respectively.
Voice recording and playback IC (APR9301-V2). It is a high-quality voice recording and playback IC. The length of message recording depends on the value of external resistor R1 connected to its pin 7. The operation modes are described below.
Recording mode. When switch S1 is pressed, LED1 glows to indicate that recording has started. Now you can speak close to microphone MIC1 in order to record your massage (in our case ‘namaste’). IC1 remains in recording mode as long as switch S1 is pressed and pin 27 of IC1 is grounded. Recording stops after 20 seconds (selected by 52-kilo-ohm resistance in this case), pin 25 of IC1 becomes ‘high’ and LED1 stops glowing.