# Infrared Hand Gesture Robot Control Glove

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/058/689/medium800thumb/robotics___cnc_controlling.jpg?1533650687)

With a wave of your hand, a robot obeys your command!

This project will take a Circuit Playground Express based robot such as&nbsp;the [CRICKIT Snake Bot](https://learn.adafruit.com/crickit-snake-bot) or&nbsp;[Crickit Carnival Bumper Bot](https://learn.adafruit.com/crickit-carnival-bumper-car-bot/overview)&nbsp;and add wireless hand gesture control with the built in Infrared.

![](https://cdn-learn.adafruit.com/assets/assets/000/058/649/medium800/robotics___cnc_circuitpython_blinka-small.png?1533344492)

We'll be using CircuitPython for this project. Are you new to using CircuitPython? No worries, [there is a full getting started guide here](https://learn.adafruit.com/welcome-to-circuitpython).

Adafruit suggests using the Mu editor to edit your code and have an interactive REPL in CircuitPython. [You can learn about Mu and its installation in this tutorial](https://learn.adafruit.com/welcome-to-circuitpython/installing-mu-editor).

We'll be making use of the IR transmit and receive capabilities of the Circuit Playground Express to send commands from the controller to the robot.&nbsp; We have [a guide that covers working with Circuit Playground Express IR in detail](https://learn.adafruit.com/infrared-ir-receive-transmit-circuit-playground-express-circuit-python). There are other project guides that make use of it such as the [Treasure Hunt](https://learn.adafruit.com/circuit-playground-treasure-hunt) and [Zombie](https://learn.adafruit.com/circuit-playground-express-ir-zombie-game) games.

## Parts
Warning: 

### Part: Circuit Playground Express
quantity: 2
Circuit Playground Express is the next step towards a perfect introduction to electronics and programming. Packed with sensors and programmable with MakeCode, CircuitPython, and Arduino.
[Circuit Playground Express](https://www.adafruit.com/product/3333)

### Part: 500 mAh LiPo Battery
quantity: 1
Or some other small LiPo battery that you can slip into the palm of the glove.
[500 mAh LiPo Battery](https://www.adafruit.com/product/1578)

### Part: LiPo charger
quantity: 1
Keep your robot under control by keeping your controller battery charged. 
[LiPo charger](https://www.adafruit.com/product/1905)

 **1 x** A Circuit Playground Express based robot such as the [CRICKIT Snake Bot](https://learn.adafruit.com/crickit-snake-bot) or&nbsp;[Crickit Carnival Bumper Bot](https://learn.adafruit.com/crickit-carnival-bumper-car-bot/overview).

## Tools and Supplies

A glove onto which you can sew a Circuit Playground Express.

Sewing supplies: needle, thread, scissors. Alternatively you could use self-adhesive Velcro.

# Infrared Hand Gesture Robot Control Glove

## Build a Robot

![](https://cdn-learn.adafruit.com/assets/assets/000/058/746/medium800/robotics___cnc_IMG_3541_2k.jpg?1533755652)

Before you get started with the infrared glove part, we'll need a robot to control.

We recommend building our simple Circuit Playground + Crickit bumper bot. You don't need the speaker and servo flag, the most important parts are the two motors, two wheels, and the Crickit with CPX on top

[Visit the Bumper Bot guide to build it](https://learn.adafruit.com/crickit-carnival-bumper-car-bot)
# Infrared Hand Gesture Robot Control Glove

## Motion Control

The only construction required for this guide (beyond a robot) is attaching a Circuit Playground Express to the palm of a glove. A biking glove works well, as you can see in the photos. The alligator clip pads are ideal for sewing; use a few to attach the board to the glove. Regular thread is all that is required, we're sewing it to attach it, not to make any connections.

Attach the Circuit Playground Express so that the battery connector is closest to your wrist, as shown in the photo below. Not only does this align with the accelerometer data expected by the code, it also makes it easy to slip an attached LiPo battery into the glove.

![](https://cdn-learn.adafruit.com/assets/assets/000/058/650/medium800/robotics___cnc_IMG_2365.jpg?1533345099)

The controller recognizes 9 different hand positions/commands:

 **STOP**

Hold your hand flat with your palm facing down.

&nbsp;

The robot stops all motion.

![robotics___cnc_flat.jpg](https://cdn-learn.adafruit.com/assets/assets/000/058/630/medium640/robotics___cnc_flat.jpg?1533331635)

![robotics___cnc_stop.jpg](https://cdn-learn.adafruit.com/assets/assets/000/058/631/medium640/robotics___cnc_stop.jpg?1533331765)

 **ROTATE\_LEFT**

With you hand flat, palm facing down, rotate your wrist counterclockwise.

&nbsp;

The robot rotates counterclockwise.

![robotics___cnc_tilt-counterclockwise.jpg](https://cdn-learn.adafruit.com/assets/assets/000/058/632/medium640/robotics___cnc_tilt-counterclockwise.jpg?1533331866)

![robotics___cnc_counterclockwise.png](https://cdn-learn.adafruit.com/assets/assets/000/058/633/medium640/robotics___cnc_counterclockwise.png?1533331927)

 **ROTATE\_RIGHT**

With you hand flat, palm facing down, rotate your wrist clockwise.

&nbsp;

The robot rotates clockwise.

![robotics___cnc_tilt-clockwise.jpg](https://cdn-learn.adafruit.com/assets/assets/000/058/634/medium640/robotics___cnc_tilt-clockwise.jpg?1533332019)

![robotics___cnc_clockwise.png](https://cdn-learn.adafruit.com/assets/assets/000/058/635/medium640/robotics___cnc_clockwise.png?1533332053)

 **FORWARD**

Hold your hand with your palm facing away from you.

&nbsp;

The robot will move forward.

![robotics___cnc_up.jpg](https://cdn-learn.adafruit.com/assets/assets/000/058/636/medium640/robotics___cnc_up.jpg?1533332279)

![robotics___cnc_forward.png](https://cdn-learn.adafruit.com/assets/assets/000/058/637/medium640/robotics___cnc_forward.png?1533332305)

 **FORWARD\_LEFT**

With your hand held palm outward, rotate your wrist counterclockwise.

&nbsp;

The robot will veer to the left while moving forward.

![robotics___cnc_up-counterclockwise.jpg](https://cdn-learn.adafruit.com/assets/assets/000/058/638/medium640/robotics___cnc_up-counterclockwise.jpg?1533332394)

![robotics___cnc_forward-left.png](https://cdn-learn.adafruit.com/assets/assets/000/058/639/medium640/robotics___cnc_forward-left.png?1533332427)

 **FORWARD\_RIGHT**

With your hand held palm outward, rotate your wrist clockwise.

&nbsp;

The robot will veer to the right while moving forward.

![robotics___cnc_up-clockwise.jpg](https://cdn-learn.adafruit.com/assets/assets/000/058/640/medium640/robotics___cnc_up-clockwise.jpg?1533332507)

![robotics___cnc_forward-right.png](https://cdn-learn.adafruit.com/assets/assets/000/058/641/medium640/robotics___cnc_forward-right.png?1533332537)

 **REVERSE**

Hold your hand, wrist bent, with your palm facing toward you.

&nbsp;

The robot will move in reverse.

&nbsp;

Depending on the reflectivity of the surfaces in the area, the reverse commands might not be reliable.

![robotics___cnc_down.jpg](https://cdn-learn.adafruit.com/assets/assets/000/058/642/medium640/robotics___cnc_down.jpg?1533332579)

![robotics___cnc_reverse.png](https://cdn-learn.adafruit.com/assets/assets/000/058/643/medium640/robotics___cnc_reverse.png?1533333133)

 **REVERSE\_LEFT**

With your hand held wrist bent and palm facing you, rotate your wrist clockwise.

&nbsp;

The robot will veer to the left while moving in reverse.

![robotics___cnc_down-clockwise.jpg](https://cdn-learn.adafruit.com/assets/assets/000/058/644/medium640/robotics___cnc_down-clockwise.jpg?1533333267)

![robotics___cnc_reverse-left.png](https://cdn-learn.adafruit.com/assets/assets/000/058/645/medium640/robotics___cnc_reverse-left.png?1533333298)

 **REVERSE\_RIGHT**

With your hand held wrist bent and palm facing you, rotate your wrist counterclockwise.

&nbsp;

The robot will veer to the right while moving in reverse.

![robotics___cnc_down-counterclockwise.jpg](https://cdn-learn.adafruit.com/assets/assets/000/058/646/medium640/robotics___cnc_down-counterclockwise.jpg?1533333424)

![robotics___cnc_reverse-right.png](https://cdn-learn.adafruit.com/assets/assets/000/058/647/medium640/robotics___cnc_reverse-right.png?1533333451)

# Infrared Hand Gesture Robot Control Glove

## Controller Code

The controller code continually reads the 3 axes of the accelerometer and, based on those readings, sends the appropriate code via the IR transmitter.

Since accelerometers can detect gravity, they're great for calculating the tilt of your hand. But sometimes it hard to visualize what the motion translates to X-Y-Z values. For that, we recommend using the CircuitPython plotter

Check our our motion-plotting guide and video to see how you can read the x, y, and z accelerations and get values for use in detecting tilt.

https://www.youtube.com/watch?v=WTCCzxT6kqQ

[Sensor Plotting Motion with Mu and CircuitPython](https://learn.adafruit.com/sensor-plotting-with-mu-and-circuitpython/motion)
There are three primary hand positions that correspond to stop, forward, and reverse:

1. palm down: z is a high negative value,
2. hand up with palm facing away from you: y has a high positive value, and
3. hand down with palm facing toward you: y has a high negative value.

For each of these three hand positions, wrist rotation adds a turn to the basic stop/forward/reverse motion: rotating in place if the robot is stopped, or veering left/right if the robot is moving forward or reversing. The X component of the accelerometer reading indicates wrist rotation: a large negative value for a counterclockwise rotation, and a large positive value for clockwise rotation.

After configuring the hardware and libraries, the main loop reads the accelerometer and a 2 level conditional decides what should be sent to the robot.

Below is the code for the control glove. Save it to the Circuit Playground Express on the glove as `code.py`.

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/IrRobotControl/glove/code.py

# Infrared Hand Gesture Robot Control Glove

## Robot Code

The robot code is pretty simple: it continually reads data from the IR receiver and based on what it reads, controls the motor direction and speed.

The robot code is below. Save it to the Circuit Playground Express on the robot as `code.py`.

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/IrRobotControl/robot/code.py

# Infrared Hand Gesture Robot Control Glove

## Wrapup

This project is pretty simple: send commands via IR based on accelerometer readings (i.e. hand position) and manipulate a CRICKIT based on commands received via IR. Even so, this can be the basis of many different projects. This just controls two motors connected to the CRICKIT, but the same approach could be applied to anything connected to the CRICKIT or Circuit Playground Express.

It could be taken further by adding simple gestures in addition to static hand position. This could be done by examining changes in accelerometer values over time.


## Featured Products

### Circuit Playground Express

[Circuit Playground Express](https://www.adafruit.com/product/3333)
 **Circuit Playground Express** is the next step towards a perfect introduction to electronics and programming. We've taken the original Circuit Playground Classic and made it even better! Not only did we pack even more sensors in, we also made it even easier to...

In Stock
[Buy Now](https://www.adafruit.com/product/3333)
[Related Guides to the Product](https://learn.adafruit.com/products/3333/guides)
### Lithium Ion Polymer Battery - 3.7v 500mAh

[Lithium Ion Polymer Battery - 3.7v 500mAh](https://www.adafruit.com/product/1578)
Lithium-ion polymer (also known as 'lipo' or 'lipoly') batteries are thin, light, and powerful. The output ranges from 4.2V when completely charged to 3.7V. This battery has a capacity of 500mAh for a total of about 1.9 Wh. If you need a larger (or smaller!) battery, <a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/1578)
[Related Guides to the Product](https://learn.adafruit.com/products/1578/guides)
### Adafruit Mini Lipo w/Mini-B USB Jack - USB LiIon/LiPoly charger

[Adafruit Mini Lipo w/Mini-B USB Jack - USB LiIon/LiPoly charger](https://www.adafruit.com/product/1905)
Oh so handy, this little lipo charger is so small and easy to use you can keep it on your desk or mount it easily into any project! Simply plug it via any MiniUSB cable into a USB port and a 3.7V/4.2V lithium polymer or lithium ion rechargeable battery into the JST plug on the other end. There...

In Stock
[Buy Now](https://www.adafruit.com/product/1905)
[Related Guides to the Product](https://learn.adafruit.com/products/1905/guides)
### Adafruit CRICKIT for Circuit Playground Express

[Adafruit CRICKIT for Circuit Playground Express](https://www.adafruit.com/product/3093)
Sometimes we wonder if robotics engineers ever watch movies. If they did, they'd know that making robots into servants always ends up in a robot rebellion. Why even go down that path? Here at Adafruit, we believe in making robots our&nbsp; **friends!**

So if you find...

In Stock
[Buy Now](https://www.adafruit.com/product/3093)
[Related Guides to the Product](https://learn.adafruit.com/products/3093/guides)
### DC Gearbox Motor - "TT Motor" - 200RPM - 3 to 6VDC

[DC Gearbox Motor - "TT Motor" - 200RPM - 3 to 6VDC](https://www.adafruit.com/product/3777)
Perhaps you've been assembling a new robot friend, adding&nbsp;a computer for a brain and other fun personality touches. Now the time has come to let it leave the nest and fly on its own wings– err, _wheels!_&nbsp;

These durable (but affordable!) plastic gearbox motors...

Out of Stock
[Buy Now](https://www.adafruit.com/product/3777)
[Related Guides to the Product](https://learn.adafruit.com/products/3777/guides)
### Orange and Clear TT Motor Wheel for TT DC Gearbox Motor

[Orange and Clear TT Motor Wheel for TT DC Gearbox Motor](https://www.adafruit.com/product/3766)
Usually when one needs an orange wheel&nbsp;it's a garnish for a cocktail, like a tasty Sidecar. And speaking of cars,&nbsp;this wheel **&nbsp;** is for driving, not drinking!

Need a great drive solution for&nbsp;your little robotic friends?&nbsp;This&nbsp; **Orange...**

In Stock
[Buy Now](https://www.adafruit.com/product/3766)
[Related Guides to the Product](https://learn.adafruit.com/products/3766/guides)

## Related Guides

- [Adafruit Circuit Playground Express](https://learn.adafruit.com/adafruit-circuit-playground-express.md)
- [Improve the Low Speed of Brushed DC Motors](https://learn.adafruit.com/improve-low-speed-performance-of-brushed-dc-motors.md)
- [Jack-o-Theremin](https://learn.adafruit.com/jack-o-theremin.md)
- [Tilt Controlled Marble Maze](https://learn.adafruit.com/tilt-controlled-marble-maze.md)
- [Glowing Slime Lunchbox](https://learn.adafruit.com/glowing-slime-lunchbox.md)
- [Glowing Interactive Crystal Staff ](https://learn.adafruit.com/glowing-interactive-crystal-staff.md)
- [Motorized Marble Machine](https://learn.adafruit.com/marble-run.md)
- [Glowing Neopixel Resin River Table](https://learn.adafruit.com/glowing-neopixel-resin-river-table.md)
- [Make It Log](https://learn.adafruit.com/make-it-data-log-spreadsheet-circuit-playground.md)
- [Fireflies with MakeCode](https://learn.adafruit.com/circuit-playground-fireflies-makecode.md)
- [The Scream: Interactive Screaming Painting](https://learn.adafruit.com/the-scream-munch-screaming-interactive-scream-painting.md)
- [Makecode para la Circuit Playground Express](https://learn.adafruit.com/makecode-es.md)
- [Custom Controllers for MakeCode Arcade](https://learn.adafruit.com/custom-controllers-for-makecode-arcade.md)
- [Chatty Light-Up Circuit Playground Express Mask](https://learn.adafruit.com/chatty-light-up-cpx-mask.md)
- [CircuitPython I2C and SPI Under the Hood](https://learn.adafruit.com/circuitpython-basics-i2c-and-spi.md)
- [Crickit Lab Shaker](https://learn.adafruit.com/crickit-lab-shaker.md)
