120 Beacon St, Somerville, MA 02143
Create Gestures with an IR Remote Controller

Welcome to programming the NeuroMaker Hand using C++ programming! In this project, you will learn the basics of programming an IR remote controller and challenge yourself to program your own commands!

Number of People

1-4 students for each available NeuroMaker Hand

Necessary Supplies

  • One fully built NeuroMaker Hand
  • One MacOS, Windows or Chrome OS computer
  • Arduino Online Editor with Arduino Create Agent fully installed
  • An IR remote controller that is included in the NeuroMaker Hand kit

Necessary Program Files

  • Please see the code breakdown in the below instructions

Preparations

  • Please ensure that the NeuroMaker Hand has working batteries. Additional power lights on the power board of the Hand should turn on when the on/off switch has been turn on. If your fingers move erratically or don’t move it all after uploading the below code this could mean that your batteries are running low.
  • Please ensure that the Arduino Create Agent and Arduino Online Editor are safe listed on your district firewall. Instructions for IT personnel is provided here: Arduino Editor Safe listing Guide
  • In case you have not yet installed the Arduino Editor, please complete the Set Up C++ Coding Environment Project
  • Please ensure the blue programming board is installed on your NeuroMaker Hand electrical assembly.

Background

You may remember from the first instructions to build the NeuroMaker Hand that we needed to make sure a black “DEMO” board was installed inside of your hand’s electrical assembly. This was the board we used to program with an IR remote control and each finger of our hand moved when we pressed a button from 0-9. Once we installed the blue programmable boards, all of a sudden our hands wouldn’t do anything if we pressed buttons on that same remote control. What is going on here?

Inside of the black DEMO board, there was code pre-installed inside of the board itself that allowed the hand to “know” what to do when we pressed buttons on our remote controls. The blue programming board is intentionally empty so we can program it with whatever we want. That being said, to make our programming board work with our IR remote controls, we are going to need to understand how these programs work and then add them in ourselves! Yes, this is a little bit more work, BUT using our new knowledge, we can program anything we want with the buttons on the remote control to do anything our NeuroMaker Hand can do!

Below, you will find a quick instructional guide on how IR sensors work, the HEX codes associated with each button of the controller and same sample code we can use to get started. We’d like to challenge you to think of whatever gestures or movements you can to connect remote control with the use of your NeuroMaker Hands!

Project Instructions

After you have challenged yourself, take a look at the code walkthrough below!

IR Remote Code Walkthrough with Mini Challenge

// IRremote - Version: 3.7.1

/*
* We need to include this library when working with the IR sensor/remote.
* Make sure to include it using the "Libraries" tab on the left.
* Search IRremote, and it should show up as a library with the same name.
*/
#include <IRremote.hpp>

//allows us to use the hand's servos
#include <Servo.h>

//This is an IR remote object that takes in the IR pin we're using as a parameter (pin the IR sensor is plugged into).
IRrecv IR(A0); 
decode_results results; //takes result from remote and stores it

//creates 5 servo objects
Servo servos[5];

void setup() {
  //begins serial connection at a baud rate of 115200
  Serial.begin(115200);
  
  //stars the IR reciever 
  IR.enableIRIn(); 

  servos[0].attach(6);
  servos[1].attach(5);
  servos[2].attach(4);
  servos[3].attach(3);
  servos[4].attach(2);

  resetFinger();
}

//Orients all fingers into an open position
void resetFinger() {
  servos[0].write(0);
  servos[1].write(180);
  servos[2].write(0); 
  servos[3].write(0); 
  servos[4].write(180);
  delay(1000);
}

//Orients all fingers into a contracted position
void grab() {
  servos[0].write(180);
  servos[1].write(0);
  servos[2].write(180);
  servos[3].write(180);
  servos[4].write(0);
  delay(1000);
}

//Example of another way to grab an obect. This example uses the thumb and pointer finger to brace the object,
//while the middle, ring, and pinky finger clamp down on the object.
void alternateGrip() {
  servos[0].write(0);
  servos[1].write(180);
  servos[2].write(180);
  servos[3].write(180);
  servos[4].write(0);
  delay(1000);
}

void loop() {
  
  //infinitely loops until the reciever gets data
  while(IR.decode(&results) == 0) {
    
  }
  
  //uses a switch statement to go through different buttons
  switch(results.value) {
    
    //user presses 0; resets all fingers
    case 0xFF6897:
      resetFinger();
      break;
    //user presses 1; orients the fingers into a grabbing gesture
    case 0xFF30CF:
      grab();
      break;
    //user presses 2; opens the thumb and pointer finger, contracts all other fingers
    case 0xFF18E7:
      alternateGrip();
      break;
  }
  
  //makes reciever check for another signal
  IR.resume();
  
}

 

en_USEnglish