How to Use a Servo With Tessel

6,146

81

3

Introduction: How to Use a Servo With Tessel

About: An engineer, seamstress, cook, coder, and overall maker. Spent a summer at Instructables; got a degree in E: Neural Engineering at Olin College; made a microcontroller (tessel.io); now thinking about climate...

Tessel is a microcontroller you program in JavaScript. It's like Arduino, but designed to be easier to use and web-friendly.

Here's what you need:

  1. Tessel
  2. Servo module
  3. Servo motor (one comes with the servo module, but there's room for 16 of them on there.)

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Install Tessel

If you haven't used a Tessel before, you should go install it.

Step 2: Plug in the Servo to the Module

Plug servo into port "1" on the module as shown.

  • the brown wire (ground) goes to -
  • the red wire (power) goes to +
  • the yellow wire (signal) goes to S

Step 3: Power the Module

Plug 5V adapter into the barrel jack on the servo module, then plug into wall power.

Step 4: Plug the Module Into Tessel

It's best to unplug Tessel from power while plugging in modules.

Plug the servo module into Tessel port A with the hexagon/icon side down and the electrical components on the top, then plug Tessel into your computer via USB.

Step 5: Install the Servo Module

Install by typing `npm install servo-pca9685` into the command line.

Step 6: Save the Code

Save this code in a text file called servo.js:

// Any copyright is dedicated to the Public Domain.
// http://creativecommons.org/publicdomain/zero/1.0
*********************************************
This servo module demo turns the servo around
1/10 of its full rotation  every 500ms, then
resets it after 10 turns, reading out position
to the console at each movement.
*********************************************/
var tessel = require('tessel');
var servolib = require('servo-pca9685');
var servo = servolib.use(tessel.port['A']);
var servo1 = 1; // We have a servo plugged in at position 1
servo.on('ready', function () {
  var position = 0;  //  Target position of the servo between 0 (min) and 1 (max).
  //  Set the minimum and maximum duty cycle for servo 1.
  //  If the servo doesn't move to its full extent or stalls out
  //  and gets hot, try tuning these values (0.05 and 0.12).
  //  Moving them towards each other = less movement range
  //  Moving them apart = more range, more likely to stall and burn out
  servo.configure(servo1, 0.05, 0.12, function () {
    setInterval(function () {
      console.log('Position (in range 0-1):', position);
      //  Set servo #1 to position pos.
      servo.move(servo1, position);
      // Increment by 10% (~18 deg for a normal servo)
      position += 0.1;
      if (position > 1) {
        position = 0; // Reset servo position
      }
    }, 500); // Every 500 milliseconds
  });
});

Step 7: Play!

In your command line, `tessel run servo.js`

Watch your servo move!

Epilog Challenge VI

Participated in the
Epilog Challenge VI

Tech Contest

Participated in the
Tech Contest

Be the First to Share

    Recommendations

    • Backyard Contest

      Backyard Contest
    • Silly Hats Speed Challenge

      Silly Hats Speed Challenge
    • Finish It Already Speed Challenge

      Finish It Already Speed Challenge

    3 Discussions

    0
    asharawy1
    asharawy1

    5 years ago

    great

    0
    asharawy1
    asharawy1

    Reply 5 years ago

    nice t