loading

Window Painting Robot (arduino, processing, accelerometer)

Featured
Picture of Window Painting Robot (arduino, processing, accelerometer)
100_5905.JPG
100_5906.JPG
100_5903.JPG
The idea for this project came from one of my favorite 'ibles: the polargraph. I loved the drawing style and thought how cool would it be to do this on the side of a building? Unfortunately the challenges to setting up such a large polargraph on a student budget pushed me to find an alternate solution, and thus started the window painting robot! This is a fairly simple robot that uses two neodymium magnets to stay up on glass walls, windows, or any surfaces less than 1" thick (one magnet is attached to the robot and the other is on the opposite side of the surface. It also work on floors, but not nearly as cool). Check it out in action! Link to video is also HERE.

With Accelerometer:


Without Accelerometer:


I am entering this project into the UP contest so if you think it is at all neat/delicious/gets you thinking then please give me a vote and help me, help you with more awesome projects =]

What I think is so enticing about this design is the wide applicability. It allows expression of ideas and creativity in normally unused spaces. The real challenge is what's the biggest glass window can you find? This also has other applications as it could clean windows, or survey the sides of buildings, draw just on floors, etc.

The advantage of this design over a polargraph or other drawing method is that it is really easy to set up and draw on any size of window. Later in the 'ible you will find the processing program I wrote for this, which takes input about your window size and robot specs and lets you to draw what you would like the robot to mark on your window; with a touch of a button it turns it into arduino code that fits in the arduino program I have supplied, so it can be easily uploaded to the robot. Then you just put the robot on the wall and watch it go to work! The autonomous nature of this design makes it free of wires while also not relying on any sort of wireless connection to do its work.

I did this project with scrap VEX metal and motors I had lying around, but don't be discouraged if you don't have those!!! It will work with any 3 wire motors (and others as well but may take minor changes to code) and whatever materials you have available (wood, metal, plastic, etc). DO NOT be discourage, you can do this project! I always challenge myself to build with what I have and this project cost me a total of $20 so really not an investment. 
 
Remove these adsRemove these ads by Signing Up

Step 1: Parts List

Picture of Parts List
Parts List
2x  3-wire Motors (I used vex 393 motors with motor controllers to make them 3-wire but any will do.)

1x  3-wire Servo (used to raise and lower the pen, I'm using a really small one. Size doesn't matter, in this case.)

1x  Arduino Board (I used an uno but any should work!)

2x  Neodymium magnets (I got mine from magnet4less.com and went with N42 counter-bored circular magnets 1" diam by 1/2" thick. These are the real crux of the whole project as they need to be strong enough to hold the robot against the wall. My robot weighs 2.5 pounds and these magnets keep it easily attached to windows up to 1" thick! Remember you can always add spacers if they are a little strong.)

1x  Battery Pack (These are to power the arduino and drive the motors, I used the vex 7.2v pack but use whatever works for you.)

4x  Wheels (You can use two but I found four to be alot more precise. Whatever they are make sure they have a rubber coating or some grippy surface.)

1x  Tiny Breadboard (This is optional as you can just wire things directly to the arduino, but it help plan the paths out.)

1x Single-Axis Accelerometer (Optional but highly recommended) I'm using one that is twenty years old so really anything will do (they can be found online for cheap). Just remember for our application the lower the g rating the better, mine is +-4g so anything around there will do.

Materials for the body (Use what you have!!!! Those who have a 3d printer, try making a chassis that way. I don't have access to something like that but the lighter, the better! I used some scrap metal.)

Gears (I used vex ones, these are needed to drive wheels if you are doing a four wheeled design. People with 3d printers can make their own but for those without access lego gears are a possibility if the mounts are drilled out. Be creative!)

Window Markers!

Random bits of wire/screws to hook everything up.

Step 2: Look at That Body

Picture of Look at That Body
For the body I used scrap metal to make a general U shape in the frame. I later added a support beam at the open end of the U to give it more strength, so I would advise you to just make a square with an opening in the center (for the servo and pen to be mounted in). The body's width should be able to fit both your motors as they will be mounted under it. Mine measures 12.5 centimeters as my motors are 5.5 cm wide. The body also should be long enough to mount both your wheels with gears to drive them. My body ended up being 15 cm long, close to a square shape. Keep in mind that the magnet will be mounted at the center of the robot's underside (see next slide for details) so make space if that is needed.

Just as a general reminder, keep it light! The lighter weight, the easier it is to maneuver. 

Step 3: Magnets (so attractive)

Picture of Magnets (so attractive)
100_5898.JPG
The next import part is to mount your magnets to the underside of the frame. As you can see in my pictures I have it along the line that the motor shafts are, so when the robot turns it revolves around the magnet and will offer little resistance to keep the driving precise. The magnet should be mounted so that when the wheels are attached and the robot is pressed against the wall it will be just a millimeter from the surface of the glass. This height is tough to gauge without the wheels added yet, but it is important to make sure you can mount the magnets and the exact height can be adjusted with washers or nuts later. I actually kept the magnet off after this point to make the rest of the building easier.

Step 4: The Wheels (of Change) Keep On Turning

Picture of The Wheels (of Change) Keep On Turning
100_5895.JPG
100_5896.JPG
The base is almost ready to move! Mount the motors to the frame. Then attach the gears and wheels to the frame. Using the VEX parts made this simple for me, but it boils down to three shafts for each side, one for each wheel and the one driven by the motor. I used gears to help add torque so the wheels wouldn't slip. After adding the wheels, you can also iron out the exact height the magnet will need to be mounted at.

Step 5: The Pen

Picture of The Pen
100_5900.JPG
For this step we will be mounting the window marker and servo t the frame. I couldn't find a great way to do this with the little space I had for it so I just zip tied the marker to the servo and the servo right onto the robot body. It turned out to be pretty rigid and the servo had enough force to make clean, continuous lines. The placement of the pen is key as the closer it is to the magnet (which is the center point that the robot turns around), the cleaner the drawings will turn out. 

Once the pen is mounted test out what servo position makes the window touching the window (down position) and what position you want to raise it to (up position). Write these down as you will need to enter them into the arduino code later.

Step 6: Arduino, Wires, and Battery - Shocking!

Picture of Arduino, Wires, and Battery - Shocking!
100_5882.JPG
100_5899.JPG
Alright, now it's time for the electronic components of the project to come together. The electronics in this project are very simple as you are just hooking up three motors to the arduino. The picture of the breadboard below shows how I set mine up. The battery pack is wired to the V-in and ground on the arduino. The V-in and ground is also sent to the two driving motors with the V-in going to the red motor wire, and the ground going to the black motor wire. Then I sent the two motor signal wires (white in my case) using yellow wire to the arduino pmw ports at 5 and 6 (my "left" motor is attached to pin 6 and the "right" is in 5).

For the servo I also attached it to the V-in and ground, and the signal wire to the arduino pmw port 3. Next, I secured my battery pack to the open space left on the robot. You also want this as close to the center of the robot (by the pen) so that the weight isn't distributed too unevenly. After this I just cleaned up the motor wires with some zip ties. 

You can also power the motors and arduino independently. Send the arduino's power source into the V-in and ground terminals on the arduino and have the motor's power source hooked up to the motors (make sure to send the motors' ground line to the other arduino ground pin). Then just send the signal wires to the appropriate terminals. 

Step 7: Accelerometer (Optional)

Picture of Accelerometer (Optional)
Now to attach the accelerometer! Mine runs of off 5v as many do so I simply wired the red and black wires straight to the arduino 5v pin and ground pins respectively. My accelerometer is analog (I think most are but am not 100% sure), so I sent the yellow wire to the a0 analog pin on the arduino. All set.

Before attaching it run a simple program that reads the accelerometer values and prints them to the screen. Find the direction that the accelerometer should be held at to get the greatest value. Then turn the accelerometer a complete 180 degrees and you should be getting the minimum value that the accelerometer will read. My max was around 600 and my min was around 400, but yours could be quite different! Write these down as you will need them for calibrating the robot in the processing sketch.

When you mount it to the robot, make sure that it will give this maximum reading when the robot is attached to the wall and "looking up" or pointed to climb upwards on the window.

To give a little more information on how this is used, the arduino code reads the accelerometer value every millisecond and uses a buffer by averaging 20 of these values before using the averaged value as the robots "current" position in the code. Using this filter my robot turns exact angles to within about 3 degrees (tough to estimate) of the desired value. This small imprecision is most likely due to the motors slowing down before stopping for an extremely short time after they have been set to neutral. 

Step 8: Processing

Picture of Processing
processingProgram.PNG
processingProgram2.PNG
proc2.PNG
Like I talked about earlier, I have designed a processing interface that will easily turn drawings into code for the robot to follow. To start the program simply download the processing sketch below, and open it using Processing. (For those who have never used processing or arduino search for the basics about them in the instructable's search bar). Just click run (it looks like a play button on a remote) and the program will open. (In the video on the first page you can see me doing exactly this).

The program only requires 4 pieces of information (5 if using an accelerometer) before you can start drawing: the time it takes your robot to do a complete 360 degree turn, the speed of your robot (cm/s), the window height, and the window width. If using an accelerometer the 360 turn time is not needed, but rather the max and minimum values for your accelerometer are specified. These are all crucial to having an accurate drawing. In the program just click on the buttons (such as window height or robot speed) to change the values. A left click increases the values and a right click decreases a values. Once you have completed the setup click the "Done" Button. A small scale version of your window will appear.

Before drawing be sure to click on the "Homepoint" button and drag it onto the mock window. Wherever you release it a small red circle will appear, this is the place that your robot must be placed to start the drawing, and it will return to that spot at the end of the drawing. 

Now to start drawing simply click and drag in the scale version of the window. Where you first click the mouse will be the start point of the line and where you release will be the end point of the line. There is also an "Undo" button in case of mistakes! Wherever you see a white line is where the robot will lower the pen and draw, between those lines it lifts the pen and moves to the start of the next drawn line. 

Once you have completed the drawing simply click the "Generate Code" button. In the bottom of the original processing sketch (the one with the code in it), a bunch of arduino commands will appear (Should say things like angleLeft(); or drive();). Scroll up to where the commands start and use ctrl - c / v to copy them all. This will be used with the arduino in the next step. (If using the accelerometer program the first command will be calibrate(values here); as this gives the robot your max and min accelerometer readings.

All the Arduino and Processing sketchs can be downloaded HERE

Step 9: Arduino

Picture of Arduino
Now you will need to open the arduino program that takes the commands from the processing sketch. It can be downloaded below. Once you've opened the sketch just paste the code you copied from the processing program into the brackets below the line that says COPY COMMANDS BELOW. Upload the arduino program to the robot and you are ready to go! (To do a different drawing just delete the old commands and copy the new ones into the same area.) If you need to change the pen servo positions I have set then just change what the "up" and "down" integers are initialized to at the top of the arduino program.

Both the Processing and the Arduino code are simple, so feel free to read through it and get a better feel for what it does. (Also it's pretty self explanatory but make sure if you're using an accelerometer to get the processing AND arduino code specified for it).

Step 10: Prospects

Picture of Prospects
I am still testing the accelerometer functions but have yet to find any problems so if you have any comments/advice on that please feel free to let me know!

As a last note I hope you enjoyed my first instructable, and please let me know of what gargantuan drawings, improvements, or general cool things you do with this idea. Thanks! Have fun!
LokeshReus10 months ago

how is that magnets sticking to the glass ?

sbrown95781 year ago

I see a lot of potential in this. You are a student? Go to businesses on holidays and put designs on the windows, have you thought of etching? Or a lace design would really be nice on any home window. You could make a pretty penny with this.

BRhyner2 years ago
Can you give me that websit with the accelerometers
Patrick S (author)  BRhyner2 years ago
Sparkfun.com sells IMU's, I recently purchased the 9150 (I think) and they also have just accelerometers.
rtw17012 years ago
Ah. I didn't see this mentioned in the instructable and I couldn't tell with picture if one was on the inside of the window.
Oh I have see someone selling a window cleaning robot but it used vacuum to hold on to window and needed to be plugged in for the power so not as portable as your idea. And was noisy from the vacuum.
Patrick S (author)  rtw17012 years ago
Thanks, I updated the intro paragraph so hopefully it's clearer.
rtw17012 years ago
You must be a great hit on Halloween. Now make the clean window robot.
Patrick S (author)  rtw17012 years ago
Haha I'll have to fish out a squigee and see what I can do!
rtw17012 years ago
I don't get this either...
hrm this should be for how it can climb on glass with magnet ? but doesnt seem to be working down there. Can you explain some of that Mizchief100 because I guess I missed my science class that day.
Patrick S (author)  rtw17012 years ago
So basically there's one magnet attached to the robot and one on the opposite side of the window. The wheels of the robot are grippy rubber and the magnet is mounted just off the glass so only the wheels are touching, allowing it to move around on the window. Hope that helps!
lilrichard2 years ago
Dude magnets were genius. Are the magnets strong enough to hold up a person??
The magnets are strong, the glass isn't.
how it can climb on glass with magnet ?
Canoeman2 years ago
I was thinking, about using a round metal disk, with three or four small casters to hold it just a milimeter off the window surface, might make the device roll freely over the window.
Patrick S (author)  Canoeman2 years ago
Go for it! Let me know how it turns out.
Cool and interesting way of sticking a bot to a window! :-) Thank you for sharing this idea with us; I like the VEX gears and tools as well.
Patrick S (author)  arduinoprojects20112 years ago
Thanks, and yes the VEX adds a lot to it.
agis682 years ago
greate instructable, giving food for thought, thanks for sharing
munng2 years ago
Hi, Mizchief100
Well done, I have not thought of using magnet to hold this robot.

You could sell these to big box stores for ad writing as well as your idea of window cleaning. This looks very patent worthy. Good job dude!
Patrick S (author)  projectbronco2 years ago
Hah hadn't even thought of that but now you have me thinking!
zvizvi2 years ago
well done! looks robust
I would definitely add obstacle detection and get curvy with some sinus functions driving PWM levels!
Patrick S (author)  zvizvi2 years ago
Great ideas! Curved lines would be something for sure. I will keep this in mind.
chuckyd2 years ago
Impressive work.
vincent75202 years ago
Hey ! What about window cleaning ???
Patrick S (author)  vincent75202 years ago
Definitely possible, you just need to attach a squigee or something to clean to the back and draw it a route to clean on the window!
vincent75202 years ago
Hey ! What about window cleaning ???
vincent75202 years ago
Hey ! What about window cleaning ???
ringai2 years ago
I was expecting something that would paint the edging on the window frame ;-)
snotty2 years ago
Am I right in presuming other magnet on the far side of the window? If so, does if ever get stuck on crud or scratch the window slightly?
Patrick S (author)  snotty2 years ago
Yep, it's on the other side of the window one. And I've never had a problem with scratching/sticking the magnet has a really smooth metal surface, but I've also wrapped it in a soft bed sheet and attached it to the window like that and it worked great as well!
Tomdf2 years ago
I've been wanting to work on something like this, but for boring practical purposes like cleaning my windows, or a submersible fish tank cleaner robot and this info will be a huge help.
I haven't used an accelerometer before, how well is that working for keeping the turning accurate?
Great instructable btw!
Patrick S (author)  Tomdf2 years ago
It's doing quite well, accurate to within 3 degrees normally. Will keep you posted!
TheThinker2 years ago
Very cool project!! Well done. Neat clean design. Thanks for sharing this with us! It has inspired me.