- I wanted to contol the CBiS micro:Bit Car via gestures whilst holding another micro:Bit (see Figure 1) I went for: - Button A in combinat...
- This is the second of a planned occasional series of posts on playing with some of the current AI specific add-on processors for Intenet of ...
- You don't need to buy a robot to get programming a robot, now there are a range of free and relatively simple to start with robot simula...
- In an earlier post I played with 4Tronix's CrumbleBot to make an edge follower robot ( http://robotsandphysicalcomputing.blogspot.co.uk/...
- In previous post I looked at a few on-line robot simulators (see links below) Programming VEX Code Programming iRobot Simulator Programming...
- Popular Posts Moving Eyes with an Adafruit Adabox kit One of the things I enjoy is a subscription to Adabox from Adafruit, ...
- How do you fancy, building and programming a Batmobile? A recently fulfilled Kickstarter project from Circuitmess allows just that https://...
- It is not physical but CBiS Education have release a free robot arm simulator for Scratch. Downloadable from their site http://w...
- For a number of years, I have been playing with robots as a means of developing programming/coding skills with students. The problem is when...
- In the previous blog posts for this 'series' "It is a good time...." Post 1 looked at the hardware unpinning some of...
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.
Showing posts with label microbit. Show all posts
Showing posts with label microbit. Show all posts
Wednesday, 31 May 2023
Popular posts May 2023
Friday, 31 December 2021
Top 10 viewed posts 2021 on the Robot and Physical Computing Blog
Speech Recognition in Scratch 3 - turning Hello into Bonjour!
The Raspberry Pi Foundation recently released a programming activity Alien Language , with support Dale from Machine Learning for Kids , tha...PS3 Controller to move a USB Robot Arm
Guest Blogger Hiren Mistry, Nuffield Research Placement Student working at the University of Northampton. How to use a PS3 Controller to...Scratch Robot Arm
It is not physical but CBiS Education have release a free robot arm simulator for Scratch. Downloadable from their site http://w...Tinkercad and Microbit: To make a neuron
The free online CAD (and so much more) package Tinkercad https://www.tinkercad.com/ under circuits; now has microbits as part of the list ...Escape the Maze with a VR robot - Vex VR
You don't need to buy a robot to get programming a robot, now there are a range of free and relatively simple to start with robot simula...Easy, Free and no markers Augmented Reality - location based AR
For a few years, I have been a fan of Aframe and AR.js - these are fantastic tools for creating web-based Virtual and Augmented Reality. No...Coral Dev Board and Raspberry Pi
This is the second of a planned occasional series of posts on playing with some of the current AI specific add-on processors for Intenet of ...Explaining the Tinkercad microbit Neural network
In a previous post, I looked at developing a neural network in Tinkercad around the Microbit (details available here ) and the whole model ...VR robot in a maze - from Blocks to Python
Recently I produced a post about playing with Vex Robotics VexCode VR blocks and the Maze Playground. The post finished with me saying I w...4tronix Eggbit - cute and wearable - hug avoider
/ The ever-brilliant 4tronix have produced Eggbit https://shop.4tronix.co.uk/collections/microbit-accessories/products/eggbit; a cute, wear...
Sunday, 26 December 2021
Hug Avoider 4 - micropython, Eggbot and speech
The last of the posts on the Hug avoider and the 4Tronix's Eggbit
4Tronix's Eggbit (in fact I bought three of them https://shop.4tronix.co.uk/collections/bbc-micro-bit/products/eggbit-three-pack-special :-) recently) is a cute add-on for the microbit. In three previous posts I looked at eggbit using microcode to produce a hug avoider - warns when people at too close.
In this post using the buttons and adding (via Microbit V2 with its speaker) simple speech
1. Buttons
Pins for the buttons
- pin8 - Green button
- pin12 - Red button
- pin14 - Yellow button
- pin`6 - Blue button
if pin12.read_digital()==1:
#Red Button
blank_it()
if pin8.read_digital()==1:
#Green button
startingMessage()
if pin14.read_digital()==1:
#Yellow button
rainbow()
if pin16.read_digital()==1:
#Blue botton
display.show(Image.ASLEEP)
2. Speech
The basis on the code is take from https://microbit-micropython.readthedocs.io/en/latest/tutorials/speech.html
mess1 = [
"This is the hug avoide",
"please keep back",
]
# Take from https://microbit-micropython.readthedocs.io/en/latest/tutorials/speech.html
for line in mess1:
speech.say(line, speed=120, pitch=100, throat=100, mouth=200)
sleep(500
The speech is difficult to hear but is fun and there are possibly ways to improve this starting with the information on https://microbit-micropython.readthedocs.io/en/latest/tutorials/speech.html
3. Overall
from microbit import *
from machine import time_pulse_us
import neopixel, speech
sonar =pin15
sonar.write_digital(0)
fireled=neopixel.NeoPixel(pin13,9)
def rainbow():
fireled[0] = (255, 0, 40)
fireled[1]= (255,165,0)
#block=yellow
fireled[2] = (255,255,0)
#block=green
fireled[3] = (0,255,0)
#block=blue
fireled [4] = (0,0,255)
# block=indigo
fireled[5] = (75,0,130)
# block=violet
fireled[6] = (138,43,178)
#block=purple
fireled[7] = (255,0,255)
fireled.show()
def blank_it():
for j in range(8):
fireled[j] = (63, 0, 0)
fireled.show()
def howfar():
sonar.write_digital(1)
sonar.write_digital(0)
timeus=time_pulse_us(sonar,1)
echo=timeus/1000000
dist=(echo/2)*34300
sleep(100)
return dist
def startingMessage():
mess1 = [
"This is the hug avoide",
"please keep back",
]
# Take from https://microbit-micropython.readthedocs.io/en/latest/tutorials/speech.html
for line in mess1:
speech.say(line, speed=120, pitch=100, throat=100, mouth=200)
sleep(500)
def buttonplay():
if pin12.read_digital()==1:
#Red Button
blank_it()
if pin8.read_digital()==1:
#Green button
startingMessage()
if pin14.read_digital()==1:
#Yellow button
rainbow()
if pin16.read_digital()==1:
#Blue botton
display.show(Image.ASLEEP)
while True:
buttonplay()
dist=howfar()
if dist>30:
pin2.write_digital(1)
pin0.write_digital(0)
display.show(Image.HAPPY)
else:
pin2.write_digital(1)
pin0.write_digital(1)
blank_it()
speech.say("back away please", speed=120, pitch=100, throat=100, mouth=200)
display.show(Image.ANGRY)
Tuesday, 29 June 2021
Microbit and Environment Measurement - Using Python
In two recent posts, Makecode was used with the Enviro:bit from Pimoroni to try out a few ideas (https://robotsandphysicalcomputing.blogspot.com/2021/06/pimoroni-envirobit.html and https://robotsandphysicalcomputing.blogspot.com/2021/06/pimoroni-envirobit-light-and-led.html ). In this post Pyton using the Mu editor was used to try out the Enviro:bit.
As in the makeCode version, Pimoroni has provided both a python library (via Github) but also within the Readme.md useful installation instructions. There is at the time of writing a possible typo; to get the BME280 sensor (temperature, pressure, humidity sensor) to work; you need to add parenthesis in the line bme = bme280.bme280()
After that, it works fine and includes potential altitude measurement which I don't think is in the Makecode version (though I could be wrong); I need to play with it a bit more.
To experiment the code below was used test reading temperature (in Centigrade), humidity (%), and altitude (feet). In the examples, currently provided with the library, I couldn't find a BME280 example but it was fairly easy to adapt the examples included to get something going.
import microbit
import bme280
bme = bme280.bme280()
while True:
reading = bme.temperature()
microbit.display.scroll("temp: ")
microbit.display.scroll(str(reading))
microbit.sleep(3000)
reading = bme.humidity()
microbit.display.scroll("humidity: ")
microbit.display.scroll(str(reading))
microbit.sleep(3000)
reading = bme.altitude()
microbit.display.scroll("Alt: ")
microbit.display.scroll(str(reading))
microbit.sleep(3000)
It is a cool and fun device to play with, though I not sure the precision of the readings shown on the microbit LEDs is really necessary :-)
Saturday, 12 June 2021
4tronix Eggbit - cute and wearable - hug avoider
The ever-brilliant 4tronix have produced Eggbit https://shop.4tronix.co.uk/collections/microbit-accessories/products/eggbit; a cute, wearable device, with ultrasonic sensors, buttons and LEDs for the microbit - I couldn't resist.
Programming is through Makecode and an extension is available, to download and install. To use the extension, at the time of writing this, go through the add extension option and use the search box to add it from https://github.com/4tronix/EggBit
So what to do with it? Inspired by social distancing (or not being a 'hugger') created it so that when people get too close the RGB LEDs go out - simple but fun. The distance is set at 20cm for testing. The code is shown below.
It was fun to do and perhaps swapping the settings around so the lights come on when people at too close might be more fun or using sound. This is a lovely device to play with and the look encourages play - just look how cute it is! The price is reasonable and the look means it has the potential to encourage a wide range of people to experiment with it.
Saturday, 6 February 2021
Making a neural network in Tinkercad from Microbits
Tinkercad and microbit neural network |
In a previous post I produced a single neuron based around microbits in Tickercad - see here.
To extend this the basic ideas discussed in that the previous post where extended to three microbit joined together. In other words a network of neurones or neural network.
Basic requirements of a neuron are
Requirements
- By altering the bias (or w0 in the example), weights change the behaviour of switches changes.
-when switch is pressed a variable x1 or x2 is set to 1 depending on which button is pressed and when released it goes to 0.
- if (bias+w1*x1+w2*x2)>=0 then a T for True appears of the LEDs otherwise F for False is shown.
So by selecting the weights and connecting the outputs (p2) from the microbits labelled as Red and Green in the image above as inputs to the yellow microbit 'neuron' we can form a neural network. Switches as the inputs and the screen on the yellow 'neuron' as the output of the network showing true (T) or false(F).
So to build a XOR from the 'neurons'
'hidden layer'
Red microbit had the variables w0 set to -1 and W1 set to 0 and W2 set 1
Green microbit had the variables w0 set to -1 and W1 set to 1 and W2 set 0
'output layer'
Yellow microbit had the variables w0 set to -1 and W1 set to 1 and W2 set 1
All of this can be found at https://www.tinkercad.com/things/hPV4nU0Asr5-smooth-bojo or through the link shown below:
Monday, 13 July 2020
Dancing Kitronik's Game Zap - reacts to music
You will glad to hear this is only a short post.
In an earlier post, Build a Disco Cube:bit that reacts to music; the vibrations of music, makes the cube sitting on a speaker with the volume pushed to 11 (just to test it of course) react to the music. The accelerometers values in the micro:bit, in the three axis, are feedback to change the neopixels colour. Simple but good fun.
With some very minor (and I do mean minor) changes it works on the Kitronik's Game Zap - eight pixels are altered at a time instead of five but apart from that nothing more. The code in python is shown below:
from microbit import *
import neopixel, random
np = neopixel.NeoPixel(pin0, 64)
while True:
for pxl in range (3,64, 8):
rd=int(abs(accelerometer.get_x())/20)
gr=int(abs(accelerometer.get_y())/20)
bl=int(abs(accelerometer.get_z())/20)
np[pxl] = (rd, gr, 0)
np[pxl+1] = (rd, gr, 0)
np[pxl-1] = (rd, gr, 0)
np[pxl+2] = (rd, gr, 0)
np[pxl+3] = (0, gr, rd)
np[pxl-2] = (0, gr, rd)
np[pxl-3] = (rd, 0, 0)
np[pxl+4] = (0, gr,0)
np.show()
I was impressed with a few tweaks it worked! Please feel to share and copy, if this useful to you please share in the comments.
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
Monday, 9 December 2019
Sphero RVR
Sphero have a track record of making well sort of fast spherical robots (along with a few Star Wars ones) in a recent kickstarter campaign they have a released a tracked robot https://www.kickstarter.com/projects/sphero/sphero-rvr-the-go-anywhere-do-anything-programmabl/description - RVR and it is still fast and fun.
It does seem to be a step up, they are allowing more customisation with a expansion port and on-board power, aimed at connecting other pieces of hardware, for example, Microbit and Raspberry Pis.Even without these it is not short of sensors and lights
The simplest way to program it is still through the Sphero Edu App and its block programming providing a quick way to get going.
This feels (to me) like a move towards the more 'traditional' robot hobbyists market - and that is fine. It comes almost completely built, so it is soon ready to go out of the box which is nice. I am interested to see what resources will be provided by Sphero through their Sphero Developer Site (https://sdk.sphero.com/), there are already some cool looking sample projects on the site https://sdk.sphero.com/samples/. So in all, I think well worth a look.
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
Tuesday, 23 April 2019
Combining Beta Edublocks and Microbit Playground
I have recently been playing with Edublocks (edublocks.org) and the 4tronix's Microbit Playground (the appropriately named Super Kit) controlling programmable pixels/neopixels and a servo.
Recently a beta version of the Edublocks (see above) has become available (https://app.edublocks.org/) so I wanted to play with it a bit and, at the same time, combine control the servo motor and neopixels together via a potentiometer (see below).
The block version of the code is shown below:
The python version
np = None
port1 = None
pot2 = None
port3 = None
from microbit import *
import neopixel
np = neopixel.NeoPixel(pin0, 8)
pin2.set_analog_period(20)# your own code
while True:
port1 = pin1.read_analog()
pot2 = port1//128
port3 = port1//8
np[pot2] = (255, 0, 128)
np.show()
pin2.write_analog(port3)
sleep(250)
np.clear()
To see it action
via GIPHY
A few thoughts on the beta version, I actually like it more than the current version for doing this kind of activity. I found it clearer to use, it was easier to know what was needed to be done with blocks around the neopixels than the previous version, which needed a little more thought.
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
Recently a beta version of the Edublocks (see above) has become available (https://app.edublocks.org/) so I wanted to play with it a bit and, at the same time, combine control the servo motor and neopixels together via a potentiometer (see below).
The block version of the code is shown below:
The python version
np = None
port1 = None
pot2 = None
port3 = None
from microbit import *
import neopixel
np = neopixel.NeoPixel(pin0, 8)
pin2.set_analog_period(20)# your own code
while True:
port1 = pin1.read_analog()
pot2 = port1//128
port3 = port1//8
np[pot2] = (255, 0, 128)
np.show()
pin2.write_analog(port3)
sleep(250)
np.clear()
To see it action
A few thoughts on the beta version, I actually like it more than the current version for doing this kind of activity. I found it clearer to use, it was easier to know what was needed to be done with blocks around the neopixels than the previous version, which needed a little more thought.
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
Saturday, 1 September 2018
Build a Disco cube:bit that reacts to music.
In a previous post Micro:bit and Cube:bit 'says' Hello I introduced the start of me playing with the 4tronix Cube:bit. One of the things I want to try is get the cube to react to music, based around the accelerometers in a micro:bit picking up vibrations. Luckily, in an earlier post, I had done something similar for the Proto-Pic Micro:pixel (see Dancing Pixels for more details).
Essentially the idea is the vibrations from the music shake the micro:bit enough to give measurable changes in three axis, and these values are used to change the pixel's colour - in fact five pixels at a time.
The code shown below is all that was needed:
from microbit import *
import neopixel, random
np = neopixel.NeoPixel(pin0, 125)
while True:
for pxl in range (2,125, 5):
rd=int(abs(accelerometer.get_x())/20)
gr=int(abs(accelerometer.get_y())/20)
bl=int(abs(accelerometer.get_z())/20)
np[pxl] = (rd, gr, 0)
np[pxl-1] = (rd, gr, 0)
np[pxl+1] = (0, gr, rd)
np[pxl-2] = (rd, 0, 0)
np[pxl+2] = (0, gr,0)
np.show()
Here it is in action:
The music used in the video is
Please feel free to improve on this.
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
Essentially the idea is the vibrations from the music shake the micro:bit enough to give measurable changes in three axis, and these values are used to change the pixel's colour - in fact five pixels at a time.
The code shown below is all that was needed:
from microbit import *
import neopixel, random
np = neopixel.NeoPixel(pin0, 125)
while True:
for pxl in range (2,125, 5):
rd=int(abs(accelerometer.get_x())/20)
gr=int(abs(accelerometer.get_y())/20)
bl=int(abs(accelerometer.get_z())/20)
np[pxl] = (rd, gr, 0)
np[pxl-1] = (rd, gr, 0)
np[pxl+1] = (0, gr, rd)
np[pxl-2] = (rd, 0, 0)
np[pxl+2] = (0, gr,0)
np.show()
Here it is in action:
The music used in the video is
Please feel free to improve on this.
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
Microbit and Cube:bit 'says' Hello
Since seeing pictures of the 4tronix Cube:bit I have intrigued by it and now I have one. So what is it? It is a 3D array of neopixel-style LEDs, or another way of describing it a programmable box of LEDs (or just good fun). The option I went for the 5x5x5 array (125 LEDs) controlling it with a micro:bit, and the base for mounting and powering the grid.
Instructions for putting it together can be found at https://4tronix.co.uk/blog/?p=1770. My main bit of advice is read the instructions carefully especially if you go for the 5x5 options, at the time of writing, you need to move a standoff around but it is all in the instructions. Admittedly I missed this step initially.
So to playtime, using a microbit I wanted to spell-out HELLO across the grid using the Micro:Bit JavaScript Blocks/MakeCode Editor. Basically, my solution revolved around creating two JavaScript functions to produce vertical and horizontal patterns on the grid (sounds good saying that - reminds me of Tron). What is very useful is 4tronix's have provided their own MakeCode package (the URL needed is in the instructions https://4tronix.co.uk/blog/?p=1770 ), this was great it made it even easier to get programming. The plan was put H is one first vertical plane, the E on the next and so on.
The code to my solution is available here https://makecode.microbit.org/_ePhFgu13i97D or can be seen or download from below.
The video below shows it in action.
It isn't the cheapest option for producing a grid of neopixel-style LEDs but it probably one of the easiest ways to do this. Quite quickly (if you read the instructions) you have a 3D array of LEDs to program. Last but not least, it is fun. Now I have to think (or rather stop thinking) about all the things I want to do with this.
Another review and related links:
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
Instructions for putting it together can be found at https://4tronix.co.uk/blog/?p=1770. My main bit of advice is read the instructions carefully especially if you go for the 5x5 options, at the time of writing, you need to move a standoff around but it is all in the instructions. Admittedly I missed this step initially.
So to playtime, using a microbit I wanted to spell-out HELLO across the grid using the Micro:Bit JavaScript Blocks/MakeCode Editor. Basically, my solution revolved around creating two JavaScript functions to produce vertical and horizontal patterns on the grid (sounds good saying that - reminds me of Tron). What is very useful is 4tronix's have provided their own MakeCode package (the URL needed is in the instructions https://4tronix.co.uk/blog/?p=1770 ), this was great it made it even easier to get programming. The plan was put H is one first vertical plane, the E on the next and so on.
The code to my solution is available here https://makecode.microbit.org/_ePhFgu13i97D or can be seen or download from below.
The video below shows it in action.
It isn't the cheapest option for producing a grid of neopixel-style LEDs but it probably one of the easiest ways to do this. Quite quickly (if you read the instructions) you have a 3D array of LEDs to program. Last but not least, it is fun. Now I have to think (or rather stop thinking) about all the things I want to do with this.
Another review and related links:
- Review https://www.electromaker.io/blog/article/building-a-cube-with-cubebit
- Lorraine Underwood's Cubert https://hackspace.raspberrypi.org/features/cubert-when-an-led-grid-wont-cut-it-take-the-blinkenlights-to-another
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
Monday, 20 August 2018
Getting Crabby with EduBlock for Microbit
This is really pulling together two recent posts, one when I started playing with Edublocks for the microbit and one about playing with BinaryBots Crab .
The BinaryBots Totem Crab is available at https://www.binarybots.co.uk/crab.aspx
Here I going to use Edublocks (https://microbit.edublocks.org/) by @all_about_code to control the claw of the Crab to close when button A is pressed (and display a C on the LEDs) and open the claw when button B is pressed. For a discussion on the Crab and what the pins are, etc goto http://robotsandphysicalcomputing.blogspot.com/2018/08/crabby-but-fun.html for more details.
The timing of the opening and closing is controlled by how long the C or O takes to scroll across the LEDs. As an aside, but I found it interesting (it appeals to my geekiness), if you save the blocks, using the Save button; it stores it as an XML file, an example extract is shown below:
Now I want to explore a little the Python editor in Edublocks; to see if it can be used to expand the range of activities. The code as it stands now:
Using some code developed by CBiS Education/ BinaryBots I have added some code to read the Crab's temperature sensor and display "Warm" or "Cold" depending on this. The code uses the struct module to convert between strings of bytes (see https://pymotw.com/2/struct/) and native Python data types. to work with the I2C bus which the Crab sensors use (more details on the bus can be found https://microbit-micropython.readthedocs.io/en/latest/i2c.html ). The code below was then download as a hex file to the microbit as before.
The Crab's reads in the temperature and displays either message "Warm" or "Cold" - currently repeatedly "Warm". The open and closing of the claws still works.
So this was a double win, I had a chance to explore whether the Edublocks Python works as advertised and it does and an opportunity to play with the Crab a bit more; a definite win-win.
Acknowledgement: Thank you to Chris Burgess and the team at Binary Bots/CBiS Education for sending me a copy of the Python code for accessing the sensors on the Crab.
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
The BinaryBots Totem Crab is available at https://www.binarybots.co.uk/crab.aspx
Here I going to use Edublocks (https://microbit.edublocks.org/) by @all_about_code to control the claw of the Crab to close when button A is pressed (and display a C on the LEDs) and open the claw when button B is pressed. For a discussion on the Crab and what the pins are, etc goto http://robotsandphysicalcomputing.blogspot.com/2018/08/crabby-but-fun.html for more details.
The timing of the opening and closing is controlled by how long the C or O takes to scroll across the LEDs. As an aside, but I found it interesting (it appeals to my geekiness), if you save the blocks, using the Save button; it stores it as an XML file, an example extract is shown below:
Now I want to explore a little the Python editor in Edublocks; to see if it can be used to expand the range of activities. The code as it stands now:
Using some code developed by CBiS Education/ BinaryBots I have added some code to read the Crab's temperature sensor and display "Warm" or "Cold" depending on this. The code uses the struct module to convert between strings of bytes (see https://pymotw.com/2/struct/) and native Python data types. to work with the I2C bus which the Crab sensors use (more details on the bus can be found https://microbit-micropython.readthedocs.io/en/latest/i2c.html ). The code below was then download as a hex file to the microbit as before.
The Crab's reads in the temperature and displays either message "Warm" or "Cold" - currently repeatedly "Warm". The open and closing of the claws still works.
So this was a double win, I had a chance to explore whether the Edublocks Python works as advertised and it does and an opportunity to play with the Crab a bit more; a definite win-win.
Acknowledgement: Thank you to Chris Burgess and the team at Binary Bots/CBiS Education for sending me a copy of the Python code for accessing the sensors on the Crab.
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...