Sunbot Version 01 uses a simple transistor circuit, which in theory, doesn’t even require an Arduino. (Though I used one).
Version 02 is a little more complicated, it uses a motor driver (L293D) and an ultrasonic sensor to avoid obstacles. It also uses an infrared transmitter and receiver to communicate between multiple robots.
Supplies
1.Circuit Layout
2. Code
3. Robot Body
4. Robot Body 2
BOT
-Arduino Nano: (or small microcontroller of your choice. These are low-cost but they require drivers: sunfounder nano, Robotshop
-Visit this site to download the appropriate driver
–Gearbox motors and wheels (2 per bot)
–Third roller wheel: (1 per bot)
–motor driver IC (L293D) or a motor driver shield if you don’t want to build from scratch, (1 per bot)
–photocells , (2 per bot)
–ultrasonic sensor, (1 per bot)
–IR emitters and receivers if communicating btwn bots, (1 set per bot)
–10K resistors (2 per bot)
–330 ohm resistor (1 per bot)
–10 uf capacitor (1 per bot)
-Hookup wire, header pins, screw terminals
POWER
I wanted my bot fully rechargeable. You could replace these sources with AA batteries. But you will need a separate power source for your wheels vs. your microcontroller.
Wheels:
–6V 1600mah rechargeable NiMh battery
–tamiya connectors for those batteries, these get connected to PCB
–NiMh charger (optional)
Nano:
–3.7V lipo
–Powerboost board kicks up the 3.7 to 5V to power Arduino
-Still testing this but in theory this board: https://www.robotshop.com/en/seeedstudio-usb-charger-power-booster-lipo-rider-pro.html, will allow me to charge the lipo from a solar panel.
ROBOT BODY
-Cardboard
-acrylics
-recycled materials
Note: I’ve compiled a list of resources for learning, and buying supplies here You can also buy a lot on Amazon these days, but if you’re new to electronics, I recommend a verified seller like Sparkfun. If you want to make one from scratch at home, try version 1, it’s a little simpler!
To speed up the process of making multiples, I had circuits fab’d through Seeed Studio (designed in Eagle). There are other pcb fabrication services out there, and you can also use the schematic to etch your own boards.
Here is an image of my schematic:
The professionally fab’d boards. Because I wanted multiple bots, this was worthwhile for me to do.
Here is a link to a zip file of the Eagle files:
SunbotEagle
I ultimately soldered header pins and screw terminals to the board, to make it easier and faster to swap out parts.
You can also follow the schematic above to wire up your robot on a breadboard. The main part of the wiring is the L293d, or motor driver. Here’s a good explanation of how that gets wired if you don’t like schematics: Motor Driver tutorial
Basically, you want to use this IC so that you can switch the polarity of your DC motors through the Arduino, which will allow each wheel to go forward to backward. Doing this allows you greater navigational abilities. You can also buy a shield to help with this, but it’s cheaper to wire yourself. And again, when thinking in terms of multiples, cost matters.
The photocells need a 10K resistor. In this image you can see the resistor is between one leg of the photocell and ground.
You connect the other side of the resistor to the Arduino. Mine are actually wired the other way, with the resistor going between the photocell and 5V. As far as I know it functions the same, it will just invert your values. So with the resistor between ground, you will get high values in high light. With the resistor between 5V you get high values in lowlight. So in my code, I have my robots look for low values, because that correlates to high light. You just want to check your serial monitor when you have it plugged in to see what kind of values you are getting before programming behavior.
Again, refer to the above schematic for my exact wiring.
If you are testing on a breadboard, I recommend checking your components in phases. IE, wire up your H-Bridge and test wheels. Wire up photocells and test via Serial monitor. Then combine.
Here is my code in the current version:
download the code Here
You’ll also need to download the following library unzip it and add it to documents–> Arduino –> libraries
Main aspects of code to play with:
if ((distance > 1) && (distance < 10)) {
turn();
}
<– current number lets it get really close [10mm] to obstacles before it turns, change 10 to a higher value, and it will turn a bit earlier [if adding plastic domes, definitely need to increase the distance that causes a turn, because they over-hang the structure]
if (lightlevel1 > 200) {
leftForward();
}
else {
leftStop();
}
<– The light levels are printed to the serial. You’ll want to test this outside, while plugged into a computer so you can read serial values, and decide what it is an appropriate level to make your bot stop in. I also have been thinking about making it stop in extremely low light, because this may signify night time, and there’s no point in having it rove around looking for light then. [Note, added that and updated code. Also useful for testing inside, you can turn of lights have them “sleep”]
IR communication
Right now, it’s very basic. When a robot has enough sun, it will begin emitting on a channel. If another robot receives the emission, we can assume it’s facing the bot that’s found sun, and it should go forward to join it. This code came from: the Sparkfun IR tutorial
void IRreceive(){
Serial.println("receive mode");
if (irrecv.decode(&results)) {
if (results.value == 0xA90) {
Serial.println("hello robot friend");
leftForward();
rightForward();
digitalWrite(LED, HIGH);
delay(500);
}
Serial.println(results.value, HEX);
irrecv.resume(); // Receive the next value
}
}
void IRemit(){
for (int i = 0; i < 3; i++) {
irsend.sendSony(0xa90, 12);
Serial.println("emitting");
delay(40);
}
irrecv.enableIRIn(); //put back into receive mode after emitting
}
In future iterations, may be interesting to compare behavior when sending and emitting IR vs. communicating via wifi.
The robot body can be made out of anything, in theory. You may want to experiment with different sized containers and plants to see how it effects your bot’s speed and performance. The battery I linked to can power a pretty heavy pot.
In a workshop, (Sunbot Swarm 1) I made robot bodies out of recycled junk with participants. But because the bots all had their sensors at different heights, they struggled to see and avoid each other. This meant they rammed into each in their quest for sunlight.
Video of the first 6 bots, over the course of about 2 hours, eventually trying to kill each other when the sunlight disappears. Guess I should have predicted that :0
To help work past this problem, I made some laser cut robot bodies out of cardboard, so that they’ll be standardized. I’d also like to consider ways to make them out of biodegradable materials like mycelium.
The chassis would probably preform better out of acrylic but I was trying to use materials that were more eco-friendly.
Here are the laser cut files, including videos for assembling the slices forms. The thin files are for 2 ply cardboard such as pictured here. The thick ones are for recycled cardboard such as Amazon boxes, if you can find enough.
Edit: After a lot of testing, I found that acrylic did ultimately yield a more stable chassis. The issue is that if the chassis can bend at all, or become mis-aligned, the wheels are likely to fall off when the bot hits a bump. I do think it’s possible to make a more stable cardboard chassis, but it would require some design changes to strengthen it.
I used an acrylic glue to strengthen the bonds between the acrylic pieces.
Full assembly instructions, with pictures, for the enclosed plant bot below:
Additional supplies:
-Plastic domes/hemispheres. These are hard to find, I got very reasonable ones from Canalplastics but don’t see them listed online. Have seen on Amazon, described as dog windows, but much more expensive. Mine were $12 a hemisphere.
-Additional hardware: threaded rods, nuts and bolts, I got the following
5″ threaded rod, 1/4″-20 thread
1/4″-20 hex nut
3/8″ screw 5-40 thread
5-40 hex nut
-Acrylic for cutting the chassis.
I assembled the structure first, (including top, even though that will not be glued) to help ensure it was square, and then applied the acrylic glue to the seams, and held it in position for a minute until it set. Wear gloves when handling this glue and have good ventilation.
I only applied the glue to the side walls, not to the lid/top piece. I let them set over night before then taking the lid off and finishing the rest of assembly.
Then I added the rear caster
Then the wheels, with long bolts. It is important to make sure the gearbox is sitting really flat and not angled.
I covered the exposed metal with electrical tape just in case it is conductive. Pictured partially covered above.
I used screw terminals for all of my sensor connections in case I need to swap out parts. And header pins for the Arduino. I cut male/female jumper wires in half and soldered male side to the pcb, and female side to the motors. That way when I put the circuit onto the chassis I can just plug the motors into the wires coming from the pcb.
The motor wires are unnecessarily long. Taped to avoid them getting in the way. Added both heat shrink and hot glue to the wires connected to the motors, because the metal tabs there break off pretty easily.
I soldered very long wires to the photocells, so they can reach all the way out of the structure to get a good reading of the light. They thread through the top of the lid. Then I added threaded rods through the holes (which are laid out in laser cut file) with nuts on either side to keep the lid securely on. Just don’t over tighten.
These rods are from McMaster Carr and are 5″ long. I needed extra length to go through the structure and to connect to the plastic domes. Pictures below will make more clear.
The next layer to come on is the bottom of the structure. My drawing is a little off, the holes were pretty tight for the sensor, so I found it easier to pop into the structure first, and then add the wires. Be sure to plug in correctly, I shorted one of them by plugging in backwards.
Light sensors and threaded rods come through the structure. Try to center the chassis underneath from left to right, but from front to back I biased it toward the front where the ultrasonic sensor is. Basically want the chassis centered under where the top piece and plant will sit, because that’s where all the weight will be.
Then connect the wires to the infrared emitter and receiver.
The plastic domes are a little tricky. I tried to center them over chassis, and mark where to drill the hole for the bolt to come through.
And then add another nut. So three total per rod. I tried just doing one on at the base of chassis and one through the dome, but I found it was more secure when I added one to the top of the chassis as well, to kind of sandwich/pressure it together and keep it square.
Repeat the marking and drilling for second dome. Note that one threaded rod is centered and one is off set to one side. You could change that in the file. I was originally going to have three rods but it was hard to fit the electronics around them in the chassis.
The plastic domes came with plastic screws but I ordered metal ones from McMaster-Carr because they look nicer. They are 3/8″ with a 5-40 thread size.
I also swapped out the plant pot to a large (20 ounce) cardboard frozen yogurt cup because it fits perfectly into the top piece. I don’t like the way that plastic pot looks overhanging the top. There are a whole bunch of plants potted into yogurt cups:
The last thing to go in is the 9V battery because that turns it on. I just kind of pull the clip down and plug it in while holding it in the air, then tuck the battery back into chassis, but could use a better system, like an on/off switch…
I have the wheels turn off in extreme darkness so sometimes I turn down the lights when plugging in the 9V battery, so wheels won’t go crazy.