120 Beacon St, Somerville, MA 02143
Build your first C++ Program

Learn how to code C++ in Arduino IDE. Create your own gestures and learn libraries, functions, variables and loops in an object oriented programming frame.


Estimated Time

1-2 hours

Number of People

1- 2 students per NeuroMaker Hand Kit

Necessary Supplies

  • One fully build NeuroMaker Hand
  • (Included in the kit) UNO programming board
  • USB cable (Included in the kit)

Necessary Program Files


Pre Check Items

  • The NeuroMaker Hand is fully built
  • Both 9V and AA batteries are installed
  • A Mac/Windows computer with network access and USB port


C++ is one of the most popular programming languages in use around the world today. Much of the code that runs your internet browser and popular online games like World of Warcraft use C++ to run their systems! C++ requires less resources to operate than other higher level languages like Python. In the world of Biomedical sciences, C++ is used from everything to power MRI machines to systems that handle patient information. At BrainRobotics, much of the code used to control the movement of the device itself is actually written in C++!

Project Instructions

Install Arduino IDE. This is the coding environment you will be using to program your hand gestures. Download the IDE via this link below:


Open up Gesture_Start.ino in the Arduino IDE to get started. This sample code is an incomplete code that needs to be finished. Follow the instructions below to complete the code.

Complete This C++ Code!

// Servo.h is a library that is needed to control the
// servo motors in a straightforward way.
// You should always include libraries at the start of your code.

#include <Servo.h>

// C++ is a great language for object oriented programming. You can treat
// “Servo” as a blueprint to create servo motor objects. When we say
// “Servo servos”, we are creating an object called “servos”, using the
// blueprint “Servo”. This will make sure that “servos” inherits all the
// properties that a servo motor needs. The “[5]” attached at the end simply means
// we created 5 servo motors, from #0 to #4, saved in an array.

Servo servos[5];

// This is the initial setup of the code. It attaches each servo motors we just created to
// a specific pin# on the actual hardware. Servo number 0-4 corresponds to thumb, index finger,
// middle finger, ring finger and little finger.

void setup() {
// put your setup code here, to run once:

// Tell all fingers to open up when the program starts.

// This “void paper” is a function. The name of the function is paper, and the return
// type is void, meaning it does not need to return anything. This function defines how
// to make a paper gesture.

void paper()
// We use servo.write to tell each servo motor we created earlier to create gestures.
// the numbers in () are default angles for eachn finger. You should only use 0-180
// which is the maximum range of the servo motors.
// To move the finger, tell the servo to move to a differennt angle. For example,
// servos[0].write(180) will move the thumb. servos[1].write(0) will move the index finger.

// This function will close all the fingers and form and rock gesture.
void rock()

void scissor()
// Complete this part of the code

void fingerWave()
// Complete this part of the code

// This void loop will loop its content indefinitely. This is the main body of the program.
// In here, you can call the above functions you just wrote.
// Make sure to add delay commands after moving a finger because the servo motor needs some
// time to move.
void loop() {
// put your main code here, to run repeatedly:



// Complete this part of the code. Add new gesture functions from above.


Upload Your Code

After the code is done, it’s time to start uploading. Use the USB to connect the NeuroMaker hand with your computer. In the Arduino IDE, go to “Tools” and choose the port connected to your hand as shown below. The port # might be different on your device.

Choose board as Arduino Uno as shown.

Run Your Code

Click the upload button shown in yellow to upload your program to the NeuroMaker Hand.