Mini Solar Car With Micro:bit

by Gurbey Demirturk in Teachers > 8

11786 Views, 116 Favorites, 0 Comments

Mini Solar Car With Micro:bit

IMG_0966.jpg
Mini Solar Car Test 2

Before we start I must say that you may use right-click to open the links on a new tab. Otherwise, it is very annoying to wait for the page to load.

Hi everyone!

So excited to share my first Instructables project. I am an educator and I build this mini solar car as part of my job.

Some of my colleagues have been working on full-size solar cars with their students to participate in Solar Car Challenge. A full-size solar car takes a lot of effort and time as you may see in the video. We wanted to democratize this project so more students can benefit from it.

We had all the materials in our Innovation Lab which is a maker-space and we have many rapid prototyping tools like 3D printers, laser cutters, micro:bit, Arduino, and Raspberry Pi. So all I need to do is to put them together.

Supplies

The car chassis, wheels, and the DC motor are based on Junior Solar Sprint Competition Kit from Pitsco because we have been hosting the competition for a while and I already had the kit.

I used 2 micro:bit boards for remote control. You can buy 1 board and 1 Go bundle from Sparkfun. Since you only need the batteries and the battery holder for the remote controller.

We had the micro:bot kit from Sparkfun but I only used the moto:bit as the motor controller from the kit.

The solar panel (You may use the solar panel that comes with the JSS Kit or any other), the charger, and the rechargeable battery are from Adafruit. I used the Adafruit solar panel because it already comes with a DC jack connector. Otherwise, you need to solder one to JSS solar panel and this is discussed in the next steps.

You may see the material list here. There are options to choose from for each item.

Build the Chassis With Some 3D Parts

Spacer 3D.png
Spacer flat side.png
Motor mount.png
IMG_0975.jpg
IMG_0976.jpg
IMG_0977.jpg
Design a Wheel with TinkerCAD

You may use this pdf guide to build the car chassis but skip the panel support member section and do not install anything other than the wheels, gears, and motor.

The pdf guide tells you to glue the DC motor to the chassis but I used a 3D-Printed mount so I would remove it when needed. I attached the STL file so you can 3D print it.

There is something called spacers in the kit to mount the metal axle to the body and it also decreases the friction. The ones that come with the kit are hollow cylinders but I designed a version with one flat side so it would be easier to glue to the chassis. The STL is also attached.

I tried designing some wheels for 3D printing as well. They are not very efficient since they do not provide enough traction on smooth surfaces.

Attaching a DC Jack Connector to Solar Panel

Adafruit charger jack.jpg
IMG_0931.jpg
IMG_0978.jpg
plug to screw terminal block.jpg
Adafruit charger 2.jpg
Adafruit solar panel.jpg

The solar charger has a DC jack. If you are going to use Pitsco solar panel you might need to solder or screw a DC jack connector to it depending on what you have already. Both panels have similar specifications so you would save money if you just purchase the Ray Catcher kit.

If you are going to use Adafruit's solar panel you may skip this part since it already comes with the connector.

Attaching 2-Pin JST to a DC Jack

IMG_0933 marked.jpg
IMG_0932.jpg
plug to screw terminal block.jpg
Adafruit charger 2 load.jpg

The moto:bit has a DC power jack and the solar charger has a 2-pin JST Load output. Therefore, we need to solder or screw a DC jack connector to a 2-pin JST wire depending on what type of DC jack you want to use. You may need to check polarity: red to positive, black to ground.

Soldering M/M Jumper Wires to Alligator Clips

IMG_0942 marked.jpg
IMG_0935.jpg
IMG_0936.jpg
IMG_0937.jpg
IMG_0938.jpg
IMG_0939.jpg
IMG_0940.jpg

*Update

Thanks to KathyCeceri that you may use these jumper wires to skip this step.

*Original Post

In this step, we are going to connect moto:bit to the DC motor. We need to solder the alligator clip(comes with the JSS kit) to one end of the M/M jumper wires. You may see the pictures for details.

You can solder jumper wires to the motor directly but if you want to remove the motor and change the gear on it, it might be harder.

The Codes

Remote Code.jpg
Driver Code.jpg
Remote Code Updated.jpg
Driver Code Updated.jpg
IMG_0942 right.jpg

Before we assemble everything we should check if the setup is actually working. We will download 2 sample codes to micro:bits before the assembly since it might be harder to connect micro:bits to the computer when everything is in place. Especially the micro:bit on the chassis will be harder to reach.

The first 2 pictures are the codes for the remote controller and, let's say, "the driver". This will help us determine if the motor is running as expected before we assemble everything.

The first code starts with the "on start" block on the left side of the picture. The "on start" is a special event that runs when the program starts, before any other event. We use this event to initialize our program.

It starts with showing the heart icon. It is a good practice to include some visual feedback for yourself so that you would know if your code is downloaded and working. Then we set up the radio channel to 1. We will do this with the other code as well so that the 2 micro:bits can recognize each other and transfer data.

I decided to move the car forward when I tilt the micro:bit remote forward(logo down / it is like showing the screen to someone else). When the logo is down the micro:bit remote will send the number "0" to driver micro:bit.

When the driver micro:bit receives "0" then we tell driver micro:bit to run the right motor forward since I connected my motor to the right motor on the moto:bit.

Then I add the "turn motors OFF" block to stop the motor after showing, up and down arrow icons. This is enough for testing but it is better to stop the motor with another input after the full assembly. Otherwise, you need to keep tilting the remote again and again.

The wheels should turn the opposite direction when you tilt the remote toward yourself(logo up). It is the same algorithm; when the logo is up, the remote sends the number "1" and the driver tells the right motor to turn in the reverse direction when it receives the number 1.

I updated the code and add the 2nd set of codes. With those codes, the car will move forward when you press button A and it will move backward when you press button B. The car should stop if you press both buttons.

With this setup, the car can only go forward and backward but I am planning to add a servo to the front to steer the car. Moto:bit has ports to connect servo motors as well.

Check the next steps if it is hard to see the code on the pictures.

Remote Code

Remote Code.jpg

This is the code for the microbit as a remote. Click here to open the code on makecode.


Driver Code

Driver Code.jpg

This is the code for the microbit on the chassis. Click here to open the code on makecode

Connect Everything and Test

IMG_0981.jpg
IMG_0983.jpg
Mini Solar Car Test

Connect everything based on the pictures above and the labels on the solar charger, BATT, and LOAD.

Assembly

IMG_0946.jpg
IMG_0981.jpg
IMG_0948.jpg
IMG_0947.jpg
IMG_0949.jpg
IMG_0952 marked.jpg
Adafruit charger capacitor.jpg
IMG_0974 marked.jpg

It is time to put things together.

Let's start with fixing the moto:bit to the chassis with 2 wood screws. I put it somewhere between the middle and front of the body but you may move it closer to the front as much as the jumper wires stretch.

Then I used brass spacers so that the solar panel sits on top of the chassis. I used 2 screws to fasten the solar panel to the chassis. Also, I used one of those screws to fasten the solar charger to the chassis as well. I solder my capacitor standing so it does not fit under the solar panel. Therefore, it has to stick out from the chassis. You may overcome this by laying down the capacitor like in the picture.

You may tape the rechargeable battery under the chassis for now. Masking tape or painter's tape works better than packing tape. I did not want to fix it permanently while still working on it but feel free to come up with your own solution.

Please refer to the pictures for details.

Final Thoughts

IMG_0965.jpg

I think this is a great project to teach how solar panels and solar cars work. It also covers some physics, engineering, and coding concepts.

You might be asking how fast it goes but that is not the scope of this project. Although, it can be improved with weight reduction, different gear ratios (Pitsco kit comes with different gears), and a better motor.

As I mentioned earlier in one of the steps you need to change the code so that the motor would not stop immediately. You just need to add another else statement to the "driver" code so that it would stop the motor when it receives a certain number and you should also update the remote controller code so that it would send that number after, let's say, you press the button A or B.

Lastly, I should start working on the steering.

I hope you would try this project and I will try to improve my instructions based on the feedback.

UPDATES

microbit Accelerometer.png
microbit_axes.png
1) remote(Bad Coding).jpg
driver V2.jpeg
2) Remote Updated.jpg
2) Driver Updated.jpg
Mini Solar Car 🚘 Updated Code

In this version, the code allows us to control the motor speed with the pitch of the micro:bit.

There are 2 versions of the code. The first 2 and the last 2 pictures are a set, "remote and driver". The last 2 are the most updated version. You may see them below

Click here for the Driver code and here for the Remote

The "rotation degrees pitch" block returns a number between -180 and 180. We assign that number to the "power" variable and send it to the "driver" micro:bit. This determines the speed and direction of the motors with the help of "if statements". In the updated version, the remote sends the number "0" to stop the car when you press button A on the micro:bit.

The speed of the motors changes between 0 and 100 and the pitch changes between -180 and 180. I did not want to deal with limiting the pitch numbers which is not a good practice but it works fine :)

I added the following note on the Remote Code 2. You need to hover your mouse on the empty square which looks like a bug and not very intuitive. So, I added the same not below;

There are 3 "radio send number power" blocks in if statements and that is not necessary. In coding terms, they are called redundant because they do the same job. You may just add one of them outside of the "if statement". This is demonstrated in the following pictures.

Steering

IMG_3903.jpg
IMG_3942.jpg
IMG_3923.jpg
IMG_3940.jpg
IMG_3939.jpg
IMG_3943.jpg
IMG_3944.jpg
IMG_3922.jpg
IMG_3947.jpg

Finally made it steer. Placed a micro-servo in front of the car and attached it to the Servo section on the motobit. Motobit has 2 ports, P15 and P16. Mine is attached to P15. Then we designed a part on Tinkercad with the help of this servo arm model to connect the servo head to the front axle.

Codes for the Steering

Driver.jpeg
Remote.jpeg

Block coding is fun and can get serious. We need to use name-value-pair for the driver(Microbit on the car) since the driver microbit will get the same range of numbers(-180 to 180) whether you tilt the remote microbit in the x(pitch) or y(roll) coordinate. In other words, the driver microbit needs to know whether it should use the received number for power(speed) or steering.

Then you use if statements to check if the "name" sent matches with the "power" or "steer" and use the received value accordingly.

The Arrows with the "show LEDs" are for visual feedback. I am not sure if these slow down the microbit to process but the steering does not work as efficiently as I hoped. Any feedback would be appreciated.

1) The code to download to the microbit on the chassis

2) The code for the microbit as a remote