Microbit Rover Code

0 views
Skip to first unread message

Derrick Drescher

unread,
Aug 3, 2024, 4:17:43 PM8/3/24
to caldipanra

The GiggleBot is an easy-to-use platform that's really great for going straight into robotics without requiring prior knowledge about programming, robotics, mechanics and so on. It is paired with the BBC micro:bit to provide an environment where you can learn coding and grow your knowledge. The micro:bit offers a drag-and-drop coding environment called Makecode. This allows you to program the GiggleBot rover in a Lego-like fashion, which is very entertaining and fun.

One of the key attractions of the micro:bit is that it provides an easy method to exchange information from one micro:bit to another. So if you have two of them, you can pass messages back and forth. The GiggleBot takes advantage of this and provides beginner friendly blocks to create your own remote control car!

The group 1 part of the bloc is setting the radio group on which the micro:bits will communicate. The two micro:bits have to be in the same group. If you have other GiggleBots in the room, each set has to be in its own group.

Before jumping into this, the GiggleBot is an easy-to-use platform that's really great for going straight into robotics without requiring prior knowledge about programming, robotics, mechanics and so on.

One of the ways to program it is with MakeCode, which is an environment where the BBC Micro:Bit can be visually programmed by drag-n-dropping blocks. This allows you to program the rover in a Lego-like fashion, which is very entertaining and fun.

Since turning to the left/right at exactly 90 degrees depends on various factors such as the surface type, battery level, load on the motors and so on, it's best to experiment with the values for the spin left for x ms block: in my case, 540 ms seems to be right value.

Also, if your GiggleBot does not go straight when commanded so, it is recommended to use the correct towards left/right by x block found in the More section of the GiggleBot package to adjust that.

Furthermore, if you don't want to reproduce the code by looking at the above screenshot, you can just copy paste the following Javascript alternative, then go in MakeCode and click on the Javascript button (next to the Blocks button) on the top of the page and put the code in there. Next, switch back to the block-based view of the code and click on Download to download the firmware.

Now, let's flash the firmware onto the BBC micro:bit board. To do that, press on the Download button that sits on the bottom left side of the screen in MakeCode and save the hex file on your computer.

Next, copy-paste that hex file over to your BBC micro:bit board. Provided you have the board connected to your computer as we did in one of the first steps, you'll see there's a virtual filesystem to which you can copy-paste files - that's exactly where the firmware (or hex file) has to be copied to.

When copying the file, you'll be able to see the BBC micro:bit's status LED flashing intermittently. When the writing process is done, the virtual filesystem will temporarily disappear only to appear again in just a few seconds.

To make things more interesting, I placed a whiteboard marker down in the center of the GiggleBot to make it draw a square while it's running. You can do that too! Go and grab one and start drawing with your rover.

And who said things have to stay unchanged? Go on and think outside the box, pun intended, and make your GiggleBot draw various shapes by tweaking the blocks in Step 4. Change the number of turns to say 8, reduce the time it spins on the spot to something like 350 ms and see what comes out of this.

MicroBlocks is a free, Scratch-like programming language specifically designed for microcontrollers. With MicroBlocks, scripts run immediately right on the micro:bit without downloading, which means you can explore blocks and easily test your code. The code continues to run when the micro:bit is disconnected from the computer, making MicroBlocks perfect for for creating projects with the Hummingbird Bit!

In MicroBlocks, you can click on blocks to run them, just like you can in Scratch. For example, drag a Hummingbird LED block into the work area and set the % parameter to 100. if you tap on this block, the LED that you connected will light up.

As you write programs, they are automatically downloaded to the micro:bit. As an example, this program makes the LED blink 10 times when button A on the micro:bit is pressed. All the yellow blocks can be found on the Control menu. Run this program once, and then disconnect the USB cord from the micro:bit. You can still press button A to run the program! Please note that the Hummingbird still needs power, so it will need to be plugged in to the battery pack or power adapter.

Since programs written in MicroBlocks are automatically downloaded to the micro:bit, it is an excellent choice for creating mobile robots, robots that can be disconnected from the computer to roam their environment. Try building a rover to use with MicroBlocks!

To create a basic program to move and avoid obstacles, use the distance sensor to detect when the rover is near a wall or another obstacle. If the rover detects an obstacle, it should back up and turn. Otherwise, the rover should drive forward. Basic code for this is shown here. Note that two rotation servos on the rover point in opposite directions. This means that to move the rover forward, the two servos must move in opposite directions.

Hi Cassim, you can either drop the file onto a microbit when it is ready to go, or to edit it further you can visit the makecode editor and drag and drop the file into the workspace. It will open in a form that can be edited.

Hi.I have two questions. I am trying to open the .hex file.What app do I use? Browser is Firefox. My project requires 5 servos to work at the same time.The Servo Lite Board allows for a max of 3.What are my options?Do you have a Servo Board to control all 5 at the same time.Thank youCassim

Trying the code withn the servo:lite attached to the microbit. I have taken the code example as is and created it from scratch, both operate correctly in the makecode emulator. However, neither seem to run on the device after transferring it to the microbit. I have transferred the flashing heart code to check power is coming from the servolite to the microbit. All OK. And double checked the spacer and screws are in the right way. I think I have just figured out what is amiss. I just purchased this and the Cut to use Servo 3 appears to have already been cut. That would explain it. I'll go back to the reseller. Cheers

Hi Deborah, it would be helpful to know what you are trying to do that the spacer is getting in the way of? If you could send a photograph to sup...@kitronik.co.uk we will be better able to assist you with your issue.

Hi Richard, on the bottom of the servo you will see a trim pot that can be adjusted with a flat bladed screwdriver. Try adjusting this slightly in one direction and then re run your code. If it gets worse try adjusting a small amount in the other direction until it improves. Continue with small adjustments until it comes to a complete stop in the middle position and you should be good to go. I hope this helps.

Hi, I've bought a servo:lite board and need help controlling a 180 degree servo. I am not a programmer, so I can only code in blocks so far. I am having trouble getting the servo stop in a middle position and stopping it reaching the end of travel, at which point it starts shaking, I guess the motor is fighting the gears.Any help much appriciated.

Meet k8, your robotics kit for learning STEM and Computational Thinking. Designed to be an accessible entry-point into the world of robotics, k8 is a great educational tool to promote problem-solving, creativity, and digital literacy in an easy and engaging way. k8 is the best friend of new explorers of the wonderful world of robotics.

InkSmith is excited to release a completely redesigned educational content package for the k8 robot. Titled Mission on the Moon, this bundle of online courses guide students through coding and robotics, imagining k8 is a miniature lunar rover in space!

That means you don't need a physical k8 robot or micro:bit to take advantage of these free resources! Learners will be able to code a 'virtual' version of the k8 lunar rover in space using Scratch and Tinkercad.

The k8 Robot's micro:bit edge connector makes it easy to share one robot among a group of 3-4 students. Students can program their micro:bit independently and then pop the micro:bit in the edge connector to test their code on the k8 robot.

Mission on the Moon is a collaborative project between Education Technology company, InkSmith, and the Faculty of Education at Wilfrid Laurier University. Funded in part by the Canadian Space Agency, the project aims to deliver lunar rover and space-themed STEM programming for Canadian youth in grades 6 to 9.

The Mission on the Moon bundle includes a series of space-themed coding and robotics modules, available in both virtual coding and physical hardware options. The Mission on the Moon bundle also comes with an Educator course which includes curriculum connections and all of the classroom-ready presentation materials for seamless delivery.

Educators wishing to use Mission on the Moon programming in their classroom can enroll in the course bundle to gain access to the 'Educator Guide' course. Within the 'Educator Guide' course, teachers will find hundreds of classroom-ready presentation materials.

The full bundle contains a series of space-themed coding & robotics modules.For each module, you will find two versions: a course designed for virtual coding, and a course designed to be used with physical robotics hardware.

Mission on the Moon is a collaborative project between InkSmith and the Faculty of Education at Wilfrid Laurier University. This program is undertaken with the financial support of the Canadian Space Agency, and aims to deliver lunar rover and space-themed STEM programming for Canadian youth in grades 6 to 9.

c80f0f1006
Reply all
Reply to author
Forward
0 new messages