Quick Look
Grade Level: High school; also scalable for middle school
Time Required: 3 hours (wild guess!)
Subject Areas: Computer Science, Physical Science, Physics, Problem Solving, Science and Technology
Maker Challenge Recap
Students work through the engineering design process as they are introduced to servos and the flex sensor. They create simple, one-jointed, finger robots controlled by Arduino. Servos are motors with feedback and are extensively used in industrial and consumer applications—from large industrial car-manufacturing robots that use servos to hold heavy metal and precisely weld components together, to prosthetic hands that rely on servos to provide fine motor control. Students use Arduino microcontrollers and flex sensors to read finger flexes, which they process to send angle information to the servos. Students create working circuits; use the constrain, map and smoothing commands; learn what is meant by library and abstraction in a coding context; and may even combine team finger designs to create a complete prosthetic hand of bendable fingers.
Maker Materials & Supplies
Flex sensor and servo circuit materials:
- computer, Windows or Mac
- Arduino software; download from https://www.arduino.cc/en/software
- SparkFun RedBoard or Arduino Uno microcontroller and programming cable; an Arduino Inventor’s Kit is recommended (some of its many components are the items listed below), such from SparkFun
- breadboards
- 10k-ohm resistors
- 180-degree servos; one comes with the Arduino Inventor’s Kit recommended above—the generic sub-micro size servo from SparkFun, or obtain higher-quality servos such as the Hitec HS-422 standard size from SparkFun
- flex sensors; one comes with the Inventor’s Kit above—a 2.2-inch flex sensor from SparkFun
- soldering iron, to prepare the flex sensors; see note below
- solid core wire
- shrink-wrap
Note: The flex sensor pins are not ideal for use with breadboards. So, in preparation for this activity, it is recommended that you solder two solid core wire leads that are at least 6-inches long onto the flex sensor. After soldering the solid core wire, apply shrink-wrap to the leads to protect the flex sensor during the activity.
Finger materials:
- Popsicle sticks
- string
- elastic bands
- glue
- tape, to affix the flex sensor to the hand; encourage students to experiment with other methods—gloves, athletic wrap and stretch fit materials (such as these cool finger sleeves from JBM) work well!
Worksheets and Attachments
Visit [www.teachengineering.org/makerchallenges/view/cub-2201-popsicle-robot-arduino-servo-flex-sensor] to print or download.Subscribe
Get the inside scoop on all things TeachEngineering such as new site features, curriculum updates, video releases, and more by signing up for our newsletter!More Curriculum Like This
Students are challenged to design and program Arduino-controlled robots that behave like simple versions of the automated guided vehicles engineers design for real-world applications. Using Arduino microcontroller boards, infrared (IR) sensors, servomotors, attachable wheels and plastic containers (...
Kickoff
(In this activity, students design simple finger robots that they control with their own fingers. To do this, they use an Arduino microcontroller and a flex sensor to read a finger flex. Then they process this information to send angle data to a servo. A servo is a motor with feedback.)
In today’s maker challenge, your task is to design a simple finger robot using the engineering design process. We will use servos—or motors with feedback—to control angular position. What does that mean? (See if students know.) That means that the servo will move to the angle that you specify and stay at that angle until you tell it to go to another angle! If an outside force or torque is applied to the servo, it will actively fight to stay at the angle. This is known as providing a holding torque.
(Prompt student interest with a question and example.) When would holding torque come in handy? Here’s a common example. Imagine this. When you steer a car or a go-kart, you apply a torque to the steering wheel. The steering linkage transfers this torque to turn the wheels. If your hands slip off the wheel mid-turn (please do not do this!), your wheels straighten out. So, to maintain the turn, you must apply a holding torque—which is what these servos do!
The Arduino microcontroller reads from the flex sensors and controls the specific signal sent to the servo. By using the Arduino microcontroller, the sensor need not be directly connected to the servo. These two circuits are isolated both physically and in code. The microcontroller is used to control the outputs based on the inputs.
Resources
- Refer to the Engineering Design Process hub on TeachEngineering to guide your students through the challenge.
- Utilize the Engineering Design Process Notebook for design process documentation.
- In the SparkFun SIK Guide, see Circuit 8 for the servo and Circuit 9 for the flex sensor: https://cdn.sparkfun.com/datasheets/Kits/RedBoard_SIK_3.2.pdf
- To get connected with Arduino: Introduction to Arduino: Getting Connected and Blinking LEDs maker challenge
- To use sensors with Arduino: Build Your Own Night-Light with Arduino maker challenge
- Flex Sensor Hookup Guide tutorial by SparkFun: https://learn.sparkfun.com/tutorials/flex-sensor-hookup-guide
- Servo Library reference by Arduino: https://www.arduino.cc/en/Reference/Servo
- Hobby Servo tutorial (more detailed) by SparkFun: https://learn.sparkfun.com/tutorials/hobby-servo-tutorial?_ga=2.84742297.1452592132.1497891440-1988227511.1497891440
- Constrain command reference by Arduino: https://www.arduino.cc/reference/en/language/functions/math/constrain/
- Map command reference by Arduino: https://www.arduino.cc/reference/en/language/functions/math/map/
- Moving average filter (smoothing) reference by Arduino: https://www.arduino.cc/en/Tutorial/Smoothing
Maker Time
In this maker challenge, students sense the level of flex in a flex sensor, use this to control a servo, and then use this system to control a simple robotic finger.
The flex sensor included in the SparkFun Arduino Inventor’s Kit is very similar to the photocell used in the Build Your Own Night-Light with Arduino maker challenge. The difference is the resistance of a flex varies based on flex instead of light levels. Like the photocell, the flex sensor requires a voltage divider circuit to convert its varying resistance to a voltage that Arduino can read.
To start, direct students to build flex sensor circuits (see Figure 1) and then use the same Arduino “sensor read code” that they developed for the Build Your Own Night-Light with Arduino maker challenge. Many flex sensors have a 100-200 “analogRead”-unit range, but as long as students see differences with varying flex, they are ready for the next step, hooking up the servo.
Tell students: Servos require a very specific signal in order to work correctly. Luckily for us, other Arduino programmers have developed an entire set of code that takes care of the tricky nuances of the signal and put this into a library. The process of hiding the programming complexity so that future users can concentrate on the relevant data is known as abstraction. To use the servo, make sure to include the servo library with the command: #include <Servo.h>. This is the first line of code, and it has no semi-colon. Once we include the library, we can define a variable as a servo, attach this to an Arduino pin (pins 9 and 10 on Arduino Uno boards are good choices for servos), and then use the “write” command to send the servo to an angle.
As necessary, refer students to the Resources for information and examples for coding servos in Arduino.
Once students have created code that reads from the flex sensor and controls the servo, it is now up to them to combine the two!
Two functions that come in handy are constrain and map. The constrain command is useful to keep the flex sensor values within a range (700–900 is typical, but varies with the sensor). Once the value is constrained, the next step is “mapping.” Servos typically go from zero to 180 degrees and have physical stops that constrain the servo to this range. How do we control a servo in the 0-180-degree range when the sensors typically output values from 700-900? One of the easiest ways to do this is to use the map command. The map command is relatively straightforward: Send it the variable to re-range, enter the first range, and then the final range. See the Resources for a full explanation of these powerful commands.
Once students have servos that respond to flex input, the fun and creativity can really begin! Continue with the following challenge prompts:
- Can you create a simple, one-jointed prosthetic finger with a Popsicle stick that you can control with a flex sensor on your own finger? (The Figure 2 example uses tape to attach the flex sensor to a finger; encourage students to try other attachment methods such as gloves or athletic wrap.)
- Can teams combine their sketches to make an entire prosthetic hand of one-jointed fingers?
- Can you make your “fingers” move smoothly? (If the joint is “jittery,” refer to the smoothing reference in the Resources. While these coding concepts are a bit more advanced, they significantly improve finger performance.)
Wrap Up
As a class, have students share, compare and reflect on what worked and what was challenging about the activity. Did the flex sensor work right away? Did the servo? What were the challenges encountered in combining the sets of working codes? If you did this maker project again, what would you change?
Servos come in all sizes, from micro-servos to gigantic industrial applications. If you had a smaller servo, what other projects can you think of? What about a larger servo?
What other projects could use a flex sensor?
Tips
Sensor Tips
- Students often confuse inputs and outputs, so it is important to emphasize that an output from a sensor is an input to the Arduino. This is a critical and often misunderstood concept.
- If you have trouble getting the flex sensor code to work, see some example code provided in the Arduino IDE (software) at: File > Examples > 01. Basics > AnalogReadSerial.
- Remember to start the serial monitor to see the values!
- If the sensor always reads 0, then it is likely connected to ground instead of the resistor-sensor junction. Likewise, if the sensor reads 1023, the sensor likely is connected directly to power.
- If sensor values do not change, verify that the breadboard is connected to the Arduino. Commonly, students connect a sensor to the breadboard rails, but forget to bring these rails back to the Arduino. Remember: No connections between the breadboard and Arduino exist until you make them.
Servo Tips
- Included with the Arduino IDE (software) are example codes to get servos working. If these codes are used and the flex/servo system does not work, then the issue likely lies with the electrical circuitry.
- To find code for troubleshooting: File > Examples > Servo > Sweep
- To find working code for potentiometers: File > Examples > Servo > Knob
- Sometimes servos start buzzing and getting warm when operated at their range limits. If this happens, try only using angles between 10 and 165, which often solves this issue.
- Students often forget to “include” the servo library prior to setup or “attach” the servo in setup. Make sure students use the servo.write command and not the analogWrite command.
Copyright
© 2017 by Regents of the University of ColoradoContributors
Daniel GodrickSupporting Program
ITL Program, College of Engineering and Applied Science, University of Colorado BoulderAcknowledgements
This activity was developed by the Integrated Teaching and Learning Program in the College of Engineering and Applied Science at the University of Colorado Boulder. Special thanks to Jacob Segil and SparkFun Education.
Last modified: May 24, 2022
User Comments & Tips