Programming 2 Servos. Learn to connect and write code to control two servos.

Similar documents
Programming a Servo. Servo. Red Wire. Black Wire. White Wire

LED + Servo 2 devices, 1 Arduino

Servo Sweep. Learn to make a regular Servo move in a sweeping motion.

A servo is an electric motor that takes in a pulse width modulated signal that controls direction and speed. A servo has three leads:

FABO ACADEMY X ELECTRONIC DESIGN

Objectives: Learn what an Arduino is and what it can do Learn what an LED is and how to use it Be able to wire and program an LED to blink

EE-110 Introduction to Engineering & Laboratory Experience Saeid Rahimi, Ph.D. Labs Introduction to Arduino

For this exercise, you will need a partner, an Arduino kit (in the plastic tub), and a laptop with the Arduino programming environment.

Coding with Arduino to operate the prosthetic arm

Lesson 3: Arduino. Goals

Mechatronics Engineering and Automation Faculty of Engineering, Ain Shams University MCT-151, Spring 2015 Lab-4: Electric Actuators

Objective of the lesson

Setup Download the Arduino library (link) for Processing and the Lab 12 sketches (link).

J. La Favre Using Arduino with Raspberry Pi February 7, 2018

Lab 2: Blinkie Lab. Objectives. Materials. Theory

Peek-a-BOO Kit JAMECO PART NO / / Experience Level: Beginner Time Required: 1+ hour

Arduino Lesson 1. Blink. Created by Simon Monk

Rodni What will yours be?

Lab 5: Inverted Pendulum PID Control

CONSTRUCTION GUIDE Robotic Arm. Robobox. Level II

Parts List. Robotic Arm segments ¼ inch screws Cable XBEE module or Wifi module

100UF CAPACITOR POTENTIOMETER SERVO MOTOR MOTOR ARM. MALE HEADER PIN (3 pins) INGREDIENTS

Scratch for Beginners Workbook

Using Servos with an Arduino

Two Hour Robot. Lets build a Robot.

CONSTRUCTION GUIDE IR Alarm. Robobox. Level I

Module: Arduino as Signal Generator

PLAN DE FORMACIÓN EN LENGUAS EXTRANJERAS IN-57 Technology for ESO: Contents and Strategies

Workshop 9: First steps in electronics

Practical Assignment 1: Arduino interface with Simulink

You'll create a lamp that turns a light on and off when you touch a piece of conductive material

Some prior experience with building programs in Scratch is assumed. You can find some introductory materials here:

Learning Objectives. References 10/26/11. Using servos with an Arduino. EAS 199A Fall 2011

MAKEBLOCK MUSIC ROBOT KIT V2.0

Arduino Setup & Flexing the ExBow

HAW-Arduino. Sensors and Arduino F. Schubert HAW - Arduino 1

Studuino Icon Programming Environment Guide

CONSTRUCTION GUIDE Capacitor, Transistor & Motorbike. Robobox. Level VII

INA169 Breakout Board Hookup Guide

Project 27 Joystick Servo Control

Internet of Things Student STEM Project Jackson High School. Lesson 3: Arduino Solar Tracker

TETRIX PULSE Workshop Guide

TWEAK THE ARDUINO LOGO

Attribution Thank you to Arduino and SparkFun for open source access to reference materials.

Internet of Things Student STEM Project Jackson High School. Lesson 2: Arduino and LED

Training Schedule. Robotic System Design using Arduino Platform

The USELESS BOX. Procedure:

// Parts of a Multimeter

The plan... CSE 6324 From control to actuators Michael Jenkin Office Hours: Sherman 1028 Wed 3-4. From the bottom up...

Inspiring Creative Fun Ysbrydoledig Creadigol Hwyl. S4A - Scratch for Arduino Workbook

1. Controlling the DC Motors

Name & SID 1 : Name & SID 2:

Milli Developer Kit Reference Application Published on Silver Spring Networks STAGE (

URM37 V3.2 Ultrasonic Sensor (SKU:SEN0001)

Veyron Servo Driver (24 Channel) (SKU:DRI0029)

Understanding the Arduino to LabVIEW Interface

Exercise 2. Point-to-Point Programs EXERCISE OBJECTIVE

Arduino Workshop 01. AD32600 Physical Computing Prof. Fabian Winkler Fall 2014

The Motor sketch. One Direction ON-OFF DC Motor

Lesson4 Obstacle avoidance car

Lab 06: Ohm s Law and Servo Motor Control

An Introduction to Programming using the NXT Robot:

Internet of Things with Arduino and the CC3000

Lab 2.4 Arduinos, Resistors, and Circuits

Servo Runner A User s Guide

Arduino STEAM Academy Arduino STEM Academy Art without Engineering is dreaming. Engineering without Art is calculating. - Steven K.

Servomotor Control with Arduino Integrated Development Environment. Application Notes. Bingyang Wu Mar 27, Introduction

Computational Crafting with Arduino. Christopher Michaud Marist School ECEP Programs, Georgia Tech

MATERIALS TO GATHER. Electronic Parts

In this activity, you will program the BASIC Stamp to control the rotation of each of the Parallax pre-modified servos on the Boe-Bot.

CNC Using the FlexiCam CNC and HMI Software. Guldbergsgade 29N, P0 E: T:

Setting up Pro Tools I/O & connecting a microphone for Recording

Electronic Project Interdisciplinary Creation by Amy Barone and Cindy Bronen

The DesignaKnit Serial Brotherlink 3

CURIE Academy, Summer 2014 Lab 2: Computer Engineering Software Perspective Sign-Off Sheet

Create Your Own World

Programming Design. ROBOTC Software

Adafruit 16-Channel Servo Driver with Arduino

MAE106 Laboratory Exercises Lab # 1 - Laboratory tools

StenBOT Robot Kit. Stensat Group LLC, Copyright 2018

the Board of Education

Using Transistors and Driving Motors

Sten-Bot Robot Kit Stensat Group LLC, Copyright 2013

Workshops Elisava Introduction to programming and electronics (Scratch & Arduino)

the Multifunctional DCC decoder for servo s and accessory s with Arduino for everybody (with a DCC central station)

Downloading a ROBOTC Sample Program

A - Debris on the Track

A - Debris on the Track

Sunday, November 4, The LadyUno Sound Unit

A - Debris on the Track

Getting Started with the micro:bit

EGG 101L INTRODUCTION TO ENGINEERING EXPERIENCE

The Robot Program Episode 002: Building JD

On the front of the board there are a number of components that are pretty visible right off the bat!

LESSONS Lesson 1. Microcontrollers and SBCs. The Big Idea: Lesson 1: Microcontrollers and SBCs. Background: What, precisely, is computer science?

ZX Distance and Gesture Sensor Hookup Guide

Content Components... 1 i. Acrylic Plates... 1 ii. Mechanical Fasteners... 3 iii. Electrical Components... 4 Introduction... 5 Getting Started... 6 Ar

MICROCONTROLLERS BASIC INPUTS and OUTPUTS (I/O)

Analog Feedback Servos

Figure 1. Digilent DC Motor

Transcription:

Programming 2 Servos Learn to connect and write code to control two servos. Many students who visit the lab and learn how to use a Servo want to use 2 Servos in their project rather than just 1. This lesson will walk you through how to wire the 2 Servos to the Arduino and write code for different servo movements. Getting 2 servos to work together can really open up your options in creating new projects. Think, for example, about a robot that can nod and shake its head!! Note: You may want to look at the instructions on connecting 1 servo before starting this activity. You may also find the Breadboard and Arduino information sheets useful. Arduino 2 Servos (I used one small servo and one big servo, but you could use 2 same sized servos) Note: the color of the wires may be different from mine, but they behave the same. Breadboard 3 red wires 3 black wires 2 white wires

1. Start by connecting one of the red wires from Vin to the positive rail of the breadboard (See Breadboard information sheet). This makes that entire column positive. 2. Next, connect one of the black wires from GND (-) to the negative rail of the breadboard. This makes that entire column negative. 3. Connect the remaining red, and black wires to their respective places on the servos. Connect a white wire to each of the yellow servo wires. 4. Connect both red wires from the servos to the positive rail. 5. Connect both black wires from the servos to the negative rail. 6. Connect the white wire from one servo to pin 9 and the other to pin 10.

1. Start by connecting the Arduino to the computer via the USB cable. Open a new sketch and delete all of the text. Also, don t forget to check that you re connected to the right port. 2. You need to tell Arduino that you are using a Servo. To do this, go to Sketch -> Include Library -> and click on Servo. This brings up #include <Servo.h>. 3. Next you need to name the Servos. Since there are 2, they each need to have a unique name. For example: smallservo and bigservo, if you re using different sized Servos, but you can call them whatever you want.

4. Next is setup. Since there are 2 servos, there will need to be 2 lines in the setup in order to attach our servos to 2 different pins. Reminder: servos always need to be attached to pins on the Arduino with the ~ next to them. (See Arduino information sheet) 5. Now we get to the loop. The following code is for a basic motion where both servos turn 180 degrees back and forth. First tell the both servos to go to 0 degrees (smallservo.write(0);) and (bigservo.write(0);). Next, put a delay so that the Arduino will wait before reading the next line of code and doing a different motion. The delay of 2000 means that the Arduino will wait 2 seconds before reading the next line of code. Next, tell the both servos to move to 180 degrees (smallservo.write(180);) and (bigservo.write(180);). Another delay of 2000 will again tell the Arduino to wait for 2 seconds before reading the next line of code which means that both servos will wait before the loop repeats.

6. If one change is made to the code above, the big servo will spin in only one direction while the small servo spins back and forth. Look at the code for the big servo. Before the delay the big servo was set to 0 degrees (bigservo.write(0);) and then later it was set to 180 degrees (bigservo.write(180);). There is a delay in between those two motions so that the servo has time to rotate before its sent a new motion. However, if you remove one of those commands, then it would only spin to one designated angle (because that s all the code would say). Below is an example of that. Note that you could also change the delays and it would affect the small servo, but the big servo is still only getting one command so it only spins to one designated angle. If you re having trouble with your code, check that you have everything spelled correctly and that you have included all of your semicolons at the end of each line. Use the Troubleshooting document to help. If your code uploaded and it still isn t working, you may have an issue with your wiring. Try pulling everything out and starting over. Sometimes it s difficult to see what the problem is until you start all over. If your wiring looks good and your code is fine, try each servo, one at a time, to see if it is an issue with the servo itself.

To really understand how the delay affects your servos, can you write a code where the small servo goes side to side quickly, say a delay of 200, and the big servo changes directions every 2 seconds? Remember, the delay tells you how long to wait before reading the next line of code and it always reads through the code in order. When it hits a delay, it waits however long you tell it before reading the next line of code. So anything you told it to do before that delay it is going to keep doing. For example, if you write, smallservo.write(0); bigservo.write(0); smallservo.write(180); smallservo.write(0); smallservo.write(180); smallservo.write(0); bigservo.write(180); smallservo.write(180); then the small servo is going to move back and forth from 0 degrees to 180 degrees and stay at each position for 200 milliseconds, but the big servo was only told to spin fast to the left, so it will do that for 800 milliseconds (4 delays of 200 each) until it is told to go fast to the right (bigservo.write(180);) down in line 11).