Introduction: Wallbots: Autonomous Magnetic Robots That Traverse Vertical Surfaces

Picture of Wallbots: Autonomous Magnetic Robots That Traverse Vertical Surfaces
This Instructable will teach you how to create magnetic robots that traverse vertical surfaces. These robots can move on any metallic walls, including elevators, whiteboards, refrigerators or metal doors.

The robots are outfitted with several light sensors, allowing them to respond to simple user interactions. My implementation supports 3 robot 'personalities', which can be changed by covering the topmost light sensor:
Red robots move fast, going towards objects (such as human hands or other robots)
Green robots move slower, turning away from objects
Yellow robots move the slowest, and stop completely when motion or objects are detected

This instructable details my first prototype. In the future I plan to build in more complex, autonomous behaviors. I will use these robots to engage people in public spaces such as elevators or hallways. In doing so, I hope to facilitate creative interaction between people and technology in mundane, everyday settings.

Stacey Kuznetsov
Human Computer Interaction Institute
Carnegie Mellon University

for Making Things Interactive, Spring '09

*** UPDATE ***
I recently made another version of this project using continuous servo's from sparkfun and a custom-cut PCB. The new robot is much much sturdier:

Step 1: Gather Materials

Picture of Gather Materials

To make one robot, you will need:

2 servo motors
4 light sensors
4 2.2 K resistors
4 10K resistors
1 100 ohm resistors
1 Arduino Mini
6 magnetic disks
1 lightweight Battery
Some hard wire (not easily bendable)
Electric Tape
Shrink Tubing
Cardboard or paper
Hot glue or epoxy

You will also need access to:
Soldering Iron
Hot glue gun (or epoxy)
Wire Cutters
Exacto Knife

Step 2: Hack the Servo Motors to Allow for Continuous Rotation (Part 1)

Picture of Hack the Servo Motors to Allow for Continuous Rotation (Part 1)

Off-the shelf servos allow for fixed motion. We want continuous rotation in order to control robot movement. You will need to make 2 simple modifications to each servo: remove the physical rotation barriers, and hack the potentiometer into always receiving a constant signal.

The black part of the motor is designed to stop movement after 180 degrees. This is done physically- there are two plastic knobs that prevent continuous movement.

1. Pry open the servo case
2. Take apart the gears
3. Cut the wires off from the black casing (the next step explains what to do with them)
4. Clip off the small plastic bearings that hinder continuos rotation

Step 3: Hack the Servo Motors to Allow for Continuous Rotation (Part 2)

Picture of Hack the Servo Motors to Allow for Continuous Rotation (Part 2)

Now 'trick' the potentiometer into always getting continuous signal
1. Cut the red, green and yellow wires from the black casing (you should have done this in the previous step)
2. Solder a 2.2K resistor between the green wire and yellow wire.
3. Solder a 2.2K resistor between the red wire and the yellow wire.

Step 4: Flip the Rotation of One of the Motors

Picture of Flip the Rotation of One of the Motors

Servos usually rotate in the same direction given the same analog signal. We'll need to arrange them symmetrically on the robot, so we'll have to reverse one of them. This can be done in code or hardware (I did hardware b/c I'm lazy with code).

To do a hardware direction reverse:
1. cut the red and blue wires that go from the motor to the motor's board
2. solder the red to the blue, and the blue to the red (criss-cross the wires)

Step 5: Re-assemble the Motors Back Together

Picture of Re-assemble the Motors Back Together

This step is easy! Gently tuck the wires back into the case of the servos as much as you can and re-assemble the gears. I couldn't get the casing to fit after I added the resistors, so I taped everything back with electric tape.

Step 6: Attach the Magnetic Wheels to Each Motor

Picture of Attach the Magnetic Wheels to Each Motor

I used hot glue to do the 'attaching'- but any type of strong adhesive should work.

1. Cut 2 equal pieces of the hard wire. It should be about 1 inch long for each wheel.
2. Hot glue each wire into the top gear of each servo. Make sure the wire is centered.
3. Hot glue 3 magnetic disks onto the end of each wire*. Make sure the disks are centered.

*actually, I've found that once the magnets are glued on, working with the servos becomes really annoying- the stick to everything. You may want to hold off and do this at the very end.

Step 7: Connect the Servos to the Arduino Board

Picture of Connect the Servos to the Arduino Board

I'm using the Arduino Servo library, so I use pins 9 and 10 to drive the motors. So my setup looks like this:

Pin 9 -> Orange wire of Servo 1
Pin 10 -> Orange wire of Servo 2

Ground -> Black wires of Servos 1 and 2
VCC -> Red wires of Servos 1 and 2

Step 8: Attach the Photoresistors to the Arduino

Picture of Attach the Photoresistors to the Arduino

Attach each photoresistor (light sensor) to the Arduino. There are 4 sensors, for the left, right, front and top of the robot.

The circuit diagram for each light sensor is shown below. One wire of the sensor goes to VCC (power). The other wire connects to the 10K and 100 ohm Resistors. The 10K resistor connects to ground. the 100ohm resistor connects to the input pin. The input (green wire) of each sensor goes to Analog Pins on the mini (A0, A1, A2, A3).

In my code, I have set it up like this:
Analog 0 -> Top Sensor
Analog 1 -> Left Sensor
Analog 2 -> Front Sensor
Analog 3 -> Right Sensor

Step 9: Connect the RGB LED to the Arduino

Picture of Connect the RGB LED to the Arduino

You can use any RGB LED, and connect it to any of the PWM pins on the Arduino. I'm only using Green and Red Colors, so my setup is:

Red-> Pin 5
Green -> Pin 6
Ground -> Ground

You may want to put a resistor between each pin and the LED (on the order of 200 ohms). I didn't do this bc my LED can take much higher current than the arduino can supply, so it will not burn out.

Step 10: Connect the Battery

Basically, any battery that supplies around 3-4volts will work, the lighter the better. I used the sparkfun Lithium battery. Attaching it is easy. Ground goes to ground, power goes to raw VCC on the arduino.

Step 11: Upload the Code Onto the Arduino

I'm pasting my code below. Each sensor is sampled, and the robot moves depending on which sensor detects a human hand, and whether or not it's red, green, or yellow (if it should move away or towards objects).

Wallbots Code
Stacey Kuznetsov
May 6, 2009
for Making Things Interactive, Spring '09

This is the basic code to drive robotic movement of 2 sevo motors based on input
from 4 light sensors. Motion supports several settings, based on the robot mode.
Red robots move fast, towards objects (when light sensors detect darkness)
Green robots move at medium speed, away from objects (away from darker areas)
Yellow robots move slowerly, and stop to blink when objects are detected

The purpose of these robots is to move on walls using magnetic wheels.
Supported movement includes right, left and forward directions. Several
speeds are implemented based on the robot mode.

The light sensors auto-calibrate on reboot or when the top sensor is covered
for more than 3 seconds.


#include <Servo.h>

// Right and left servos
Servo servo1;
Servo servo2;

// Light Sensors
int topSensor = 0; //700
int leftSensor = 1; /// Threshhold is 400
int frontSensor = 2; //400
int rightSensor = 3; //300

// Hardcoded thresholds (not used because we auto-calibrate)
int topThreshhold = 400;
int leftThreshhold = 550;
int frontThreshhold = 200;
int rightThreshhold = 650;

// Current robot type (red gree or yellow)
int STATE = 0;

// State values
int RED = 0;
int GREEN = 1;
int ORANGE = 2;

// Pins to drive the top tri-color LED
int redPin = 5;
int greenPin = 6;

// Values to hold sensor readings
int front;
int right;
int left;
int top;

// Auto-calibrate light sensor thresholds
void calibrate() {
long int val = 0;
for (int i = 0; i<5; i++) {
val += analogRead(frontSensor);
frontThreshhold = (val /5) - 80;
val = 0;

for (int i = 0; i<5; i++) {
val = val + analogRead(topSensor);

topThreshhold = (val /5) -200;

val = 0;
for (int i = 0; i<5; i++) {
val += analogRead(rightSensor);
rightThreshhold = (val /5) - 100;
val = 0;
for (int i = 0; i<5; i++) {
val += analogRead(leftSensor);
leftThreshhold = (val /5) - 100;

// Print threshold values for debug
Serial.print("top: ");
Serial.print("right: ");
Serial.print("left: ");
Serial.print("front: ");


void setup()
// turn on pin 13 for debug
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
// setup sensor pins
for (int i = 0; i<4; i++) {
pinMode(i, INPUT);
// generate a random state
STATE = random(0, 3);


void turnLeft()

for (int i = 0; i<20; i++) {

void turnRight() {
for (int i = 0; i<20; i++) {


void goForward(int del = 20) {
for (int i = 0; i<20; i++) {

void stop() {

void start() {


// Set the color of the top tri-color LED based on the current state
void setColor(int color) {
if (color == RED) {
digitalWrite(greenPin, 0);
analogWrite(redPin, 180);
else if (color == GREEN) {
digitalWrite(redPin, 0);
analogWrite(greenPin, 180);
else if (color == ORANGE) {
analogWrite(redPin, 100);
analogWrite(greenPin, 100);

// Blink the yellow color (when robot is confused)
void blinkOrange() {
for (int i = 0; i<5; i++) {
analogWrite(redPin, 100);
analogWrite(greenPin, 100);
digitalWrite(redPin, 0);
digitalWrite(greenPin, 0);

analogWrite(redPin, 100);
analogWrite(greenPin, 100);


void loop()

top = analogRead(topSensor);
long int time = millis();
while (analogRead(topSensor) < topThreshhold) {
delay(10); // while there is an arm wave from the user don't do anything
if ((millis() - time) > 3000) {
// if the sensor was covered for more than 3 seconds, re-calibrate

// if the top sensor was covered, we change state
if (top < topThreshhold) {
STATE = (STATE+1) %3;
Serial.print("CHANGED STATE: ");

// Read the other sensors
right = analogRead(rightSensor);
left = analogRead(leftSensor);
front = analogRead(frontSensor);

if (STATE == RED) {
// go towards objects
if (front < frontThreshhold) {
} else if (right < rightThreshhold) {
} else if (left<leftThreshhold) {
} else {
if (STATE == GREEN) {
// go away from objects
if (front < frontThreshhold) {
int dir = random(0,2);
if (dir == 0 && right > rightThreshhold) {
} else if (dir == 1 && left > leftThreshhold) {
} else if (right < rightThreshhold) {
if (left > leftThreshhold) {
} else {
} else if (left<leftThreshhold) {
if (right > rightThreshhold) {
} else {
} else {

if (STATE == ORANGE) {
// only move if there are no hand motions- otherwise blink
int dir = random(0, 3);
if (left<leftThreshhold || right<rightThreshhold ||
front<leftThreshhold) {
} else {
if (dir == 0) {
} else if (dir == 1) {
} else if (dir == 2) {

Step 12: Create the Robot Casing

Picture of Create the Robot Casing

Since this robot will move vertically, it is important to make the casing as light as possible. I used cardboard, but paper or lightweight plastic will work too.

Before doing this step, make sure the code works and you can tell which servo is right and which is left.

I hot-glued the servos onto the cardboard base, and arranged the sensors to be on top, right, left, or front of the robot. I then created 'walls' of the case with more cardboard. I cut out the holes to fit light sensors and motor gears. The top of my robot is just a piece of paper!

... and you're done!


BUZZBOT (author)2016-02-23

Super cool! You could also have add-ons for the white board like markers and erasers!;)

SamuelAaronWard (author)2014-12-08

Neat gizmo! Did you consider, rather than using magnets as wheels, using rubber wheels for traction and mounting neodymium magnets on the bottom of the robot - so close to the level of the surface that the magnetic force would be strong enough to hold the robot to a vertical surface? That seems to me a better solution. I would think that having the magnets make direct contact with the surface, would make them difficult to turn, slow, and not provide enough traction. Just a thought.

Also, the circuit is a rat's nest of wires. Why not make a small PCB?

Overall, nice project! :)

Akin Yildiz (author)2014-09-03


kalaquin (author)2013-04-15

Amazing I am going to build this soon

djatico69 (author)2012-07-04

just wanna ask if you have any programs on the part of arduino...

Mic100 (author)2012-02-02

Very nice and good instructables for how to hack mini servo to
Thacks :)

crak-a-bottle (author)2011-01-18

I'm not great at electronics, but most of this makes sense and it looks awesome :)
BUT anyone know how I'd go about using a picaxe instead of arduino? Thanks muchly :)

Sovereignty (author)2010-12-01

It'd be nifty to have them clean yer windows; one on each side, like them aquarium magnets. Switch out the marker tail for a squeegie and Windex.

J-Five (author)2010-11-25


Skyriam (author)2010-11-10

This is awesome! Absolutely loved the second version of the robots. How do you make them to follow a person/object? Thanks for your time!

Carnavislol (author)2010-09-08

Very nice I will be making this soon.

Thegame995 (author)2010-09-02

Wow! This is incredible! Do you sell 1 of each one?

midnsun183 (author)2010-08-15

you sir are a modern Mozart! BRAVO!

Default117 (author)2010-08-08

It would be better if yellow robots would bite your hand instead :)

PS118 (author)2009-05-11

These things are so cute! I think it's a travesty that this one wasn't "featured". BTW, How much does one cost? Also, since they travel on whiteboards, it could be fun to give them a marker "tail" so they make designs in their travels.

raykholo (author)PS1182010-08-05

I love the marker tail idea! That would be so cute. Cost wise: the servos he uses are $10 each. An arduino like his is in the range of $20. Add headers (the connectors), the leds and photocells, and shipping, and I would say that each one cost him around $70. I could make it quite a bit cheaper though, just by using a different microcontroller and buying cheaper servos in bulk.

peanutgnome (author)raykholo2010-08-05

the opposite would be fun too - add an eraser and these would be like the Roomba robotic vacuums, but for the whiteboard. Turn them on when you leave at night and come in to a clean board in the morning!

raykholo (author)peanutgnome2010-08-05

lol. Wow this is a fun thread to be participating in! Given the processing power of arduino, I would get some proximity sensors and maybe a compass sensor, so that this thing can go up until it senses the edge, turn to the right and go for a bit, then go down and do the next row, and so on. Only thing is that you would need to install a ledge at the top much like the one on the bottom that holds the markers.

staceyk (author)raykholo2010-08-05

I recently made another version of this using continuous servo's from sparkfun ( - $13)

Some pictures here

And a demo video

 used a custom-cut PCP, which cost me $89 for about 20ish boards?
So I think the price per one is
$26 for servos
$5 magnets
$20 arduino
$5 for the custom cut board
$2-3 for wires, LED's, resistors, etc

So about $60 just for the robot itself. Then, the price goes up depending on what sensors/lights/etc you put on it. Photocells are less than a dollar, so  is a hall effect sensor- which you can use to detect when the robot is about to climb off a magnetic surface.

raykholo (author)staceyk2010-08-05

perfect timing, posting that video. I must say, using the hall effect sensor as you have just described is pretty genius. I had not thought of that. I am definitely going to be making something like this bot in the future, as soon as I can clear some time to do so. I would make the pcbs by hand, and I use the raw atemega chip + oscillator right on the pcb to save money. Not much to say for the servos. Also helps that I have a fully stocked workshop for everything else.

staceyk (author)raykholo2010-08-06

how do you print your own pcb?

raykholo (author)staceyk2010-08-07

There are some great instructables here for home etching pcbs. I'm working on getting access to a CNC mill (also some great instructables here for that), but right now I use the toner transfer method and chemicals.

Cynar (author)raykholo2010-08-06 Good little miniture servo that might be helpful

pocketspy (author)PS1182010-08-06

I like the marker idea. If you could use a smart board like Mimeo, that my ex, an art teacher uses, you could have them create art and 'save' it to your computer.

Cynar (author)2010-08-06

If you added a larger flat magnet in the middle of the robot it would give you a bit more weight to play with(just need to be careful of slippage). Good show though :-)

louisr90 (author)2009-06-15

how exactly would u upload the code the the control circuit and is there anyway for u to make a "kit" that other people could buy

staceyk (author)louisr902010-08-06

Yea i have a pcb, and bunch of extra boards i printed back in the day. it's pretty easy to put together

rlmagidson (author)2009-11-24

I've read in many projects about the "how" of hacking servos, but I don't really get the "why." Why is it better to hack a servo than just buy a (cheaper) motor that already allows for full rotation?
Thanks for taking the time to educate me.
- Russ

raykholo (author)rlmagidson2010-08-05

Servos are an easier alternative to using dc motors such as hobby or gear motors. They feature a built in gearbox and drive circuitry. Say a servo costs 10 bucks. If you get a hobby motor for $1 , you still need gears and drive circuitry. The common L293D dual motor drive chip (aka dual half bridge) costs about 5 bucks. Not to mention this requires more pins of your microcontroller (like arduino) vs. a servo only requiring one. A gear motor (with a built in gear box) will typically cost more than a servo itself. So... servos are quick, cheap(er), and are generally more convenient. In a project like this, there's no space to build 2 gearboxes with about a 120:1 gear ratio each. It also leaves a lot less room for error. I can't tell you how many robots I've built where the fatal error was an ever so tiny flaw in the gear train.

nak (author)raykholo2010-08-05


vonPongrac (author)rlmagidson2009-11-28

Becouse it has got already build in drive transfer and you only mount wheels when you hack servo.

Munchys (author)2010-08-05

They look like moving led stop/street lights

AndyGadget (author)2009-05-08

It would be fascinating to have a LED at the back of each robot and give them an occasional light homing behaviour. You could than have a 'crocodile' of magnetic minibots.

raykholo (author)AndyGadget2010-08-05

So now we can move this project into swarm robotics with infrared leds and recievers as the primary form of communication.

marc.cryan (author)2010-08-05

Well done!

kinomix (author)2010-08-04

I think its awesome

killerdark (author)2010-08-04

Well done!

crossfire (author)2010-08-04

I love it! Can you make a kit for it?

noik (author)2010-08-04


kcls (author)2010-08-04


shawntherobot (author)2009-10-08

you should enter this into the arduino contest

robot797 (author)2009-05-13

do you sell them i wanna buy 2 of them

magicpocket (author)2009-05-10


Bongmaster (author)2009-05-09

what changes would need to be made if u were to use LEDs for the light sensors? (due to me only having one LDR). i understand the LED wouldnt be a very good light sensor but it can be one aparenty :)

munchman (author)Bongmaster2009-05-09

You can't use an LED in place of an LDR, an LED only emits light, it cannot detect it.

Bongmaster (author)munchman2009-05-10

actually it can. even tho its not made to do so. its prolly not that good at it tho, but they have been used in applications like LED tables that react to movement, the LEDs that are used as the sensors are used in between the ones that give light. check the arduino site, there are examples.

DemonDomen (author)2009-05-08

You should use a board to mount the electronics. You will use less wire, it will be more robust and possibly take up less space.

jeff-o (author)DemonDomen2009-05-09

It's fine for a prototype, but yeah, a custom PCB would be most excellent.

Bongmaster (author)2009-05-08

kool looks like the kind of code i need for my R2 :3

About This Instructable




More by staceyk:Arduino PCR (thermal cycler) for under $85DIY Projects, Communities and CulturesAir quality balloons
Add instructable to: