Robots and getting computers to work with the physical world is fun; this blog looks at my own personal experimenting and building in this area.
Saturday, 2 May 2020
Programming Robots Virtually 3: LEGO EV3
In this series of posts, I am going to look at experimenting with a few tools that allow robots to be simulated, programmed, these are ideally web-based, free and simple to use. In this post,the focus is on one that has been around for a while Makecode for the LEGO Mindstorms EV3 robotics kit available at https://makecode.mindstorms.com/#editor another example of the flexible MakeCode format. A very useful guide to using this coding tool is available at https://makecode.com/blog/lego/05-15-2018
This time it does not give you a built robot but a programmable simulation of the Brick, all the sensors and motors; which it automatically connects together depending on the code (see above). I like this idea it means it is flexible, as well as encouraging thinking about the design and operations of the programs before trying it out physically.
So to experiment with it. I played with a number of elements:
When touch sensor is pressed (looks like a box with a cross on it) drive one of the motors forward, when that sensor is released the motor reverses. Following this I added the ultrasonic sensor (the one that looks like two eyes); when an object is near (controlled in the simulator by moving the slider upwards), the motors B and C rotate 5 times. The code is relatively easy and can be seen below.
Now to play with the brick itself. The first operation, is when it starts add a 'mood' set of wide-open eyes in this case, on the Bricks screen, when the enter button [the central button on the brick], show a happy face on the screen, wait and add a purring sound and write Be Happy on screen. Lastly when Red (a set of pressable colours appears near the sensor) is detected using the colour sensor put an expression on screen and when blue detected put a closed-eyed expression on screen (the code is shown below and all the code at https://makecode.com/_016aUf2YtDx6 might need to change it to blocks by changing a tab at the top of the screen)
Opinion.
I like Makecode anyway, but I think this is another good use of it. There is no installation needed to run the code and simulator and no LEGO has to be bought. If you have a Mindstorms EV3 kit, you can download your code to a physical EV3 robot (or whatever you have built using EV3). I would love to see in the comments what people have done with it as well.
Play with it yourself below:
The code used is available at https://makecode.com/_016aUf2YtDx6
All opinions in this blog are the Author's and should not in any way be seen as reflecting the views of any organisation the Author has any association with. Twitter @scottturneruon
Subscribe to:
Posts (Atom)
Who wants to produce AI produced cartoon strips
Question: How easy is it produce a comic/cartoon using genetative AI? Let's start with using ChatGPT4o to produce cartoons. The idea wa...