[go: up one dir, main page]

0% found this document useful (0 votes)
121 views13 pages

Instructables Maze Robot Student Guide

The document provides a guide for building and programming a maze robot using various materials including an Arduino board, servos, and a joystick. It outlines the necessary components, setup instructions, and code snippets to control the robot's movement based on joystick input. Additionally, it includes tips for adjusting servo positions to ensure proper functionality and balance of the robot.

Uploaded by

harleenpangu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
121 views13 pages

Instructables Maze Robot Student Guide

The document provides a guide for building and programming a maze robot using various materials including an Arduino board, servos, and a joystick. It outlines the necessary components, setup instructions, and code snippets to control the robot's movement based on joystick input. Additionally, it includes tips for adjusting servo positions to ensure proper functionality and balance of the robot.

Uploaded by

harleenpangu
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Maze Robot Guide

Materials

• 3D printed parts
• UNO R3 Board ATmega328P (Arduino Uno R3 equivalent)
• 2 SG90 micro servos w/ servo arms and screws
• KY023 joystick
• 13 Metric M2 Phillips head self tapping screws
• 4 male to male jumper wires
• 4 male to female jumper wires
• 1/4” steel ball
• 2 1/8 x 5/16 rivets (just the head)
• 2x - 4-40 x 1/2" machine screw
• 2x - 4-40 machine screw nut
1 2 3

4 5 6
7

GND 5V

+5V

GND
8 Maze Robot Program Part 1 9
First you need to tell the void setup() is the
Arduino how to use servos.
You do this by adding the section where we write
servo library and giving the instructions that
your servos names. Arduino will do only
once when we first plug
Type this: it in.
; means the end of a single
instruction
We will first define
{ } tells the beginning and end of our pins so the Arduino
a section of the program will know what we
connected to it and
what it should do with
Next you will tell the it.
Arduino all of your
variables. Arduino won’t
know how to do anything
unless you first do this.

They will look like this:

int var=#; VRXpin is the variable


we set at the beginning
int = integer (a math word that means whole
number) that defines our VRX
joystick being
var = variable (a data item that may take on more connected to A0 on our
than one value during the runtime of a program) 10 Arduino. We are now
Var can be anything you
void loop () is where we write the instructions that will run telling the Arduino
want, but it should make that this is an input.
sense to you. over and over until we turn it off.
This tells the Arduino
Our first 2 variables will We will be telling the Arduino to move our servos (OUTPUT) a to look for information
tell our Arduino information certain way when we move the joystick (INPUT). from our joystick when
about our joystick.
Our first instruction will take a number from the joystick, we move it. Later we
plug it into a math equation and solve it. Then it will use will also define
Type this:
the answer to that math equation to tell the servo where to outputs so it will know
move. You will type: how to talk to our
servos to move. VRYpin
is for when we move the
joystick the other
VRX is the pin on our
joystick and A0 is analog direction.
input 0 on the Arduino.
X = move left to right
VRY is another pin on our
***You might notice that our VRXpin and VRYpin are working Y = move up and down
joystick and A1 is analog
with the opposite servo. This is because we are using the
input 1 on the Arduino.
joystick backwards to fit into our robot.
Maze Robot Program Part 2
11 12
These are the rest of your These are the rest of your setup instructions that
variables. your program will only run once.

These variables tell the Arduino


where you connected the servos. These instructions tell the Arduino pins 9 and 10 are
outputs going to the 2 servos.

; Be sure to end
each line with a
semicolon. It is WV stands for “Write Value”. Each
just like ending a of these define the variable used
sentence with a to tell the angle to which the
servo will move. These numbers
period. will be the answer to the math These instructions attach our servos so that they can
equation Arduino is solving using be controlled as a servo.
the number given from the
joystick. Be sure this sections ends with a bracket }
0
0

These are the rest of your instructions.


13
These define the variables that
will be the numbers coming from
the joysticks.

Remember WVx and WVy are the answers to the math


equations solved by Arduino using the numbers inputed
dt stands for “delay time”. This by the joystick. These instructions use WVx and WVy
variable defines the wait time in and write those values to the servos to make them
the program. move. Without these instructions, your servos
wouldn’t do anything.

These define the range of how far


the servos will move. Without
these the servo would move so far This tells the Arduino to wait just a little bit
that it would launch the ball. before it repeats these instructions. Remember that
everything in “void loop()” will repeat over and over
0 until you turn it off.
0 Notice that the section ends with a }.
These variables are used to adjust
our servos so that they point
If you forget your ; and }, your robot won’t work.
straight up and balance the maze.
14

A1 A0

VRy

VRx

~9 ~10
15 16

X Y

Look to see which servo moves when you move the


joystick left and right. The servo that moves is
the X servo.

17 18

X Y

Move the joystick forward and backward. The servo


that moves is the Y servo.
19 X Y 20

MOVING THE
SERVO ARM BACK
AND FORTH BY
HAND WILL BREAK
IT!!!

Move the joystick left and right and up and down. When the
joystick is in the center, both servo arms should be pointing
straight up. If they aren’t you have to adjust the code in your
program.

Go to the top section of your code and look for

int adjustX=0;
int adjustY=0; 21
Go up or down 1 number at a time. adjustX is probably between
20 and 25. adjustY is probably between 4 and 10.

Like this:

int adjustX=23;
int adjustY=7;

When you are finished, unplug the robot from the computer.
M2*8mm
X- Servo

22 23

This and maze ball


hole on right.

24 25
X- Servo

26
28
Servo Arm Screw

Servo Screw

27 Servo Arm Screw

Servo Screw
You want to make sure your maze is balanced.

Go back to the top section of your code and look again for

29 int adjustX=0;
int adjustY=0;
Go up or down 1 number at a time. adjustX is probably between
20 and 25. adjustY is probably between 4 and 10.

Like this:

X int adjustX=23;
int adjustY=7;

30 HAVE FUN!

You did it! Now sign your code like this:


// Coded by John Doe
Coding Cheat Sheet

You might also like