Wallbots: Autonomous Magnetic Robots That Traverse Vertical Surfaces





Introduction: 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

To make one robot, you will need:

2 servo motors http://www.rctoys.com/rc-toys-and-parts/DF-SRV-6G/RC-PARTS-DRAGANFLY-SERVOS.html?utm_source=googlebase_froogle&utm_medium=US&utm_term=DF-SRV-6G
4 light sensors http://www.goldmine-elec-products.com/prodinfo.asp?number=G14025
4 2.2 K resistors
4 10K resistors
1 100 ohm resistors
1 Arduino Mini http://www.arduino.cc/en/Main/ArduinoBoardMini
6 magnetic disks http://www.kjmagnetics.com/proddetail.asp?prod=R8201
1 RGB LED http://www.superbrightleds.com/pdfs/RGB-1WS.pdf
1 lightweight Battery http://www.sparkfun.com/commerce/product_info.php?products_id=731
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)

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)

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

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

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

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

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

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

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

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!



    • Water Contest

      Water Contest
    • Oil Contest

      Oil Contest
    • Creative Misuse Contest

      Creative Misuse Contest

    50 Discussions

    Hi staceyk. Its a kool project. am trying to replicate but am facing following issues.

    1. Single battery even a 9v is not able to power 2 servo and arduino uno. if i use single battery the servos move at very slow pace and that too out of sync. Adding individual batteries makes my car too heavy.

    2. Placing just 2 tyres keeps my car off balance. i have to add one universal tyre in front to balance it.

    Any suggestions

    My assembly items

    1. Arduino uno board

    2 Two SG 90 continuous rotation servo motors

    3 HS 05 BT

    4 US distance sensor

    5. Plastic bottle caps acting as tyres

    6 Breadboard small

    7 9v HW batteries - 3 nos

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

    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! :)

    Amazing I am going to build this soon

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

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

    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 :)

    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.

    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!

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

    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.

    4 replies

    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.

    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!

    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.

    I recently made another version of this using continuous servo's from sparkfun (http://www.sparkfun.com/commerce/product_info.php?products_id=9347 - $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.