Showing posts with label micro:bit. Show all posts
Showing posts with label micro:bit. Show all posts

Sunday 18 December 2016

4Tronix Bit:Bot - now there is a good idea.

When I first heard of this robot, my first thought was what a great idea; a robot with neopixels (I know I should be saying 'smart RGB LEDs' but neopixels is so much more snappier) controlled via a micro:bit.





A good starting point for learning more about this robot, is the details on the 4Tronix site/blog, which includes build guidance and programming instructions for micropython and PXT. Though for the micropython code you might need to change pinX.digital_write() to pinX.write_digital() where X is the pin number.

My play code was to randomly select which neopixels to light up, I didn't include code to turn them off so multiple ones can be on. The robot is driven forwards, waits, backward, waits, turns to the right and then the left; and then repeats. 

Code:
from microbit import *
import neopixel, random

np = neopixel.NeoPixel(pin13, 12)

def forward(n):
    pin0.write_digital(1)
    pin8.write_digital(0) 
    pin1.write_digital(1)
    pin12.write_digital(0)
    sleep(n*1000)
    
def halt(n):
    pin0.write_digital(0)
    pin8.write_digital(0)
    pin1.write_digital(0)
    pin12.write_digital(0)
    sleep(n*1000)
    
def backward(n):
    pin0.write_digital(0)
    pin8.write_digital(1) 
    pin1.write_digital(0)
    pin12.write_digital(1)
    sleep(n*1000)

def right_turn(n):
    pin0.write_digital(1)
    pin8.write_digital(0) 
    pin1.write_digital(0)
    pin12.write_digital(1)
    sleep(n*1000)

def left_turn(n):
    pin0.write_digital(0)
    pin8.write_digital(1) 
    pin1.write_digital(1)
    pin12.write_digital(0)
    sleep(n*1000)

while True:
    pxl=random.randint(1,11)
    rd=random.randint(1,32)
    gr=random.randint(1,32)
    bl=random.randint(1,32)
    t1=random.randint(10,100)
    np[pxl] = (rd, gr, bl)
    np.show()
    forward(1)
    halt(1)
    backward(1)
    halt(1)
    right_turn(1)

    left_turn(1)

The video below shows it in action, the code is simple but this is a lovely robot to program especially if the mu editor is used.




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 31 October 2016

Simple (and temporary) Halloween Hack


This really is a simple one. A Glowbug (or a NeoPixel) with the data in, Ground and 5v connected pushed into the neck of the balloon, then inflated the balloon. The neck of the balloon and wires are twisted tightly and insulating tape used to provide a bit of a seal.

The data in wire is connected to Pin 0 of a Micro:Bit and the other two wires are attached to the corresponding connections of the Micro:Bit. The code below randomly selects the colours and the length of the delay before changing colour.

from microbit import *
import neopixel, random

np = neopixel.NeoPixel(pin0, 1)

while True:
    rd=random.randint(1,254)
    gr=random.randint(1,254)
    bl=random.randint(1,254)
    t1=random.randint(200,2000)
    np[0] = (rd, gr, bl)
    np.show()
    sleep(t1)

The problem is a slow leak means it only stays inflated for a short while.


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 24 October 2016

Dancing pixels

In previous post I played with using the combination of the Proto-Pic Micro:pixel and Micro:Bit to react, using the accelerometer, to music through a computer speakers. 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 pixels colour.



The latest version of this uses most of pixels.




Coded in micropython using the Mu editor.

from microbit import *
import neopixel, random

np = neopixel.NeoPixel(pin0, 32)

while True:
    for pxl in range (2,32, 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()

Video of it action, using royalty-free music Electro Deluxe by My Free Mickey feat. Gurdonark. http://dig.ccmixter.org/files/myfreemickey/48180





As one of the reviewers on Proto-Pic site states, the box the Micro:pixel comes in does make a good diffuser.

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 22 October 2016

Disco micro:pixel


In a previous post Proto-Pic board, Microbit and Micropython I played with the Proto-Pic micro:pixel 4x8 NeoPixel board. 

This post is just a short description of a quick play with making it flashing blocks of different colours across the board. The routine produces five random numbers (three to define the colours, one for which pixel is selected and the last for the delay each iteration). The idea of being - a pixel is selected, but so are the ones either side of it, each one has a different combination of the colour values, but only two of the pixels are turned off after the delay.

from microbit import *
import neopixel, random

# Setup the Neopixel strip on pin0 with a length of 2 pixels
np = neopixel.NeoPixel(pin0, 32)

while True:
    pxl=random.randint(1,30)
    rd=random.randint(1,32)
    gr=random.randint(1,32)
    bl=random.randint(1,32)
    t1=random.randint(10,100)
    np[pxl] = (rd, gr, bl)
    np[pxl-1] = (gr, bl, rd)
    np[pxl+1] = (bl, rd, gr)
    np.show()
    sleep(t1)
    np[pxl] = (0, 0, 0)
    np[pxl+1] = (0, 0, 0)

The video below shows the routine in action. There is no connection between the pixels and the music on the video - but making the connection between music and the pixels would be an interesting project.




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

Thursday 20 October 2016

micro:pixel board, micro:bit and micropython

A new (or to me at least)  addition to devices you can attach a Micro:Bit to, is the Proto-Pic micro:pixel 4x8 NeoPixel board; essentially a board with 4 x8 grid of NeoPixels that you plug the Micro:Bit into. Following the advice of the website the  values of RGB are all set to 32 or below to avoid pulling too much power. Pin0 is used to write to. You will need to use the Mu editor for this.





Two tests were tried

Example 1: To get the pixels to appear to light up from the last to the first one.

from microbit import *
import neopixel

np = neopixel.NeoPixel(pin0, 32)


while True:

    for x in range(0, 32):
        for y in range(0, (32-x)):
            np[y] = (y, 32-y, 1)
            if (y>0):
                np[y-1]=(0,0,0)
            np.show()
            sleep(30)




Example 2: To randomly select a pixel and its colour.

from microbit import *
import neopixel, random

np = neopixel.NeoPixel(pin0, 32)

while True:

    pxl=random.randint(0,31)
    rd=random.randint(1,32)
    gr=random.randint(1,32)
    bl=random.randint(1,32)
    np[pxl] = (rd, gr, bl)
    np.show()
    sleep(500)
    np[pxl] = (0, 0, 0)




This is a good, fun board to play with; relatively easy to use.





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

Thursday 6 October 2016

Micro:bit sings - sort of

Just a short post today on getting the Micro:bit to sing using micropython. The process is covered very well in the Micro:bit-Micropython documentation. This post is just my notes really of what I did.

The goal was to the try and replicate a bit of the intro to Kraftwerk's The Man-Machine (the repeating of Machine)- I came nowhere near it but it was fun trying.

Everything needs to be spelt out in Phonemes, which is a bit of a challenge, but I only had one word to do so that was ok. The Micro:bit-Micropython documentation has a list of the Phonemes allowed, you do need to get them right this was the most common error I found with the code. Pins 0 and 1 had croc-clips connecting them to the first and third parts on a speakers 3.5mm plug (as above) - thank you to Sway Grantham for showing me that.

from microbit import *
import speech

while True:

    speech.sing("MEYSHEYN  ", pitch=90,speed=100)
    speech.sing("MEYSHEYN  ", pitch=70, speed=80)
    speech.sing("MEYSHEYN  ", pitch=60,speed=60)


It is good fun, but develop it away from others, it has the potential to annoy.

It also works with 4Tronix's (thank you for the suggestion) Micro:Bit PlayGround - only one connection needed this time.



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 3 October 2016

Playing with 4Tronix's Micro:bit Playground

As much as I like the simplicity and flexibility of Crocodile Clips connecting components to a Micro:Bit, it can get a bit of a rat's nest of wires (especially if you are as messy as I am!). 4Tronix's have released their Micro:Bit PlayGround (http://4tronix.co.uk/store/index.php?rt=product/product&path=89&product_id=580)which is a board that has 3.5mm jack plugs to connect to a range of Gizmos (their phrase not mine) to which the Micro:Bit is screwed into. The battery pack is integrated onto the board on its back (see image below)



The Micro:Bit screws into the PlayGround via five screws which also for the connection between the PlayGround and the 'bit'. 

Below via the three cables connecting 3.5mm plugs, I have attached a 'Dial' (a potentiometer ) and two Flames (neopixels) to change the LED/neopixel's colours by rotating the Dial. Pin 0 has the 'Dial' attached and Pin 1 has the two Flames (neopixels) attached the out from the first goes in as input of the second via one the cables. 





Code
Essentially vary the 'Dial' varies the R,G,B values going to the two Flames/neopixels and so varying their colours. The code used is shown below.

from microbit import *
import neopixel

# Setup the Neopixel strip on pin0 with a length of 2 pixels

np = neopixel.NeoPixel(pin1, 2)

while True:

    s1=int(pin0.read_analog()/5)
    np[0] = (255, s1, 255-s1)
    np[1] = (s1,255, 255-s1)
    np.show()





Video of it in action





Thoughts
I like the idea that the cable doing both the power and control for the Gizmos, it does simplify building a little, more importantly it does produce less clutter (not so many wires). The whole unit with the batteries installed is a little weighty but that does give it at the same a sense of sturdiness which is a positive feature for just playing around  - you wouldn't use it for wearables. Not using croc clips also avoids issues with the clips slipping off with rough handling. 

Nice little arrangement which I am enjoying playing - is for everyone? Probably not, but does provide a sturdy system to experiment with some standardised units.


Related Links
Micro:Bit Playground - Starter Kit
Traffic lights - Microbit, GlowBugs and micropython


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 17 September 2016

Python Junkbot - PyCon UK 2016

Poster presented at PyCon UK 2016, 17th September 2016.



Pyconuk16 junkbots from Scott Turner

DOI: 10.13140/RG.2.2.28682.67520

For more details on the three builds:






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 August 2016

UFO has landed

CBiS Education generously sent me two of their new range of robotics development kits - BinaryBots (https://www.binarybots.co.uk/makers.aspx), these are a range of cardboard based kits (so far a robot and a UFO) with electronic components for example LEDs; sensors and buzzers,  depending on the kits. What makes the kits interesting though is they are designed to be controlled by either by a BBC Micro:bit or a CodeBug.

This blog documents, briefly, an initial play with the UFO kit (see below) using a Micro:Bit for control. 


The UFO model came together readily, the instructions were fairly easy to follow. Personally, a feature I especially liked about the model was the LEDs being both on the top and bottom of it - increasing its usefulness. CBiS EducationThey have also provided a webpage / portal with some example projects and code. 




My first project I built, was to pulse the LEDs on and off (one set of LEDs on Pin 0, the other on Pin 1). Pin 2 was connected to the buzzer, so produce a low buzz every few seconds. The code below is written using the Block Editor (https://www.microbit.co.uk/create-code)

The video below shows the LEDs pulsing. I do need to decorate the UFO though!




Looking forward to playing with it further.

Related
http://robotsandphysicalcomputing.blogspot.co.uk/2016/08/ufo-detects-light.html


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.

Friday 19 August 2016

Micro:bit Junkbot for use in schools


A new direction has been developed for the junkbot project (http://junkbots.blogspot.co.uk/); previously Raspberry Pis have been used to control the junkbot’s movement (http://robotsandphysicalcomputing.blogspot.co.uk/2016/01/python-junkbot.html) – but what about the recently released Micro:Bits; can it be used to control a junkbot?

Matthew Hole, a student from Wrenn Academy, Northamptonshire ; has been investigating this idea whilst on a Nuffield Research Placement (http://www.nuffieldfoundation.org/nuffield-research-placements) working with Dr Scott Turner, University of Northampton. The project was to look into developing junkbots controlled using a Micro:bit and also to produce some materials for schools to use with or without outside assistance.






What is a Junkbot?
For this project, it is a moving ‘bot’ made from waste materials, combined with an electric motor and a programmable device (in this case a Micro:Bit) to control (or try) it. An example is shown above. More details on junkbots can be found at http://junkbots.blogspot.co.uk/


Approach used in the project.
A Micro:Bit was selected for two reasons. First, there was been a BBC supported project to give year 7 (or equivalent) students a Micro:bit (http://www.bbc.co.uk/programmes/articles/4hVG2Br1W1LKCmw8nSm9WnQ/the-bbc-micro-bit), so they are available in the schools. Secondly, Kitronik produce a motor driver board, and provide quite a bit of support for it, for the Micro:Bit (the latest version of the board can be found at https://www.kitronik.co.uk/5620-motor-driver-board-for-the-bbc-microbit-v2.html ). Using Micropython via the online editor https://www.microbit.co.uk to program the board and therefore the junkbot connected. The board with the Micro:Bit attached can be seen in the figure above carried on the junkbot.

An example piece of code is shown below:

from microbit import *

def startIt():
   pin8.write_digital(1)
   pin12.write_digital(0)
   pin0.write_digital(1)
   pin16.write_digital(0)    

def leftTurn(duration):
   pin8.write_digital(0)
   pin12.write_digital(1)
   sleep(duration)
   
def stopIt():
   pin8.write_digital(1)
   pin12.write_digital(1)
   sleep(2000)

while True:
   startIt()
   
   if button_a.is_pressed():
       leftTurn(100)
   
   if button_b.is_pressed():
       stopIt()



Suggested Resource List
  • Small Electric Motor
  • Kitronik Motor Board
  • Battery Pack
  • BBC Micro:bit
  • Pens
  • Junk (Can or Bottle)
  • Wires
  • Tape
  • Scissors
  • Broken Propeller or un-balanced load
  • Screw Driver


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.

Wednesday 3 August 2016

Traffic lights - Microbit, GlowBugs and micropython

In a previous post, I got a GlowBug to work with a micro:bit (http://robotsandphysicalcomputing.blogspot.co.uk/2016/08/microbit-and-glowbug.html) . In this post, I will show a relatively simple traffic lights system produced by turning off and on the pixels via a micro:bit.




Code
from microbit import *
import neopixel

# Setup the Neopixel strip on pin0 with a length of 3 pixels
np = neopixel.NeoPixel(pin0, 3)

while True:
    #red
    np[0] = (255, 0, 0)
    np[1] = (0,0, 0)
    np[2] = (0,0,0)
    np.show()
    sleep(1000)
    #red and orange
    np[0] = (255, 0, 0)
    np[1] = (255, 69, 0)
    np[2] = (0,0,0)
    np.show()
    sleep(1000)
    #green only
    np[0] = (0, 0, 0)
    np[1] = (0, 0, 0)
    np[2] = (0,255,0)
    np.show()
    sleep(1000)
    #orange
    np[0] = (0, 0, 0)
    np[1] = (255, 69, 0)
    np[2] = (0,0,0)
    np.show()
    sleep(1000)





It is simple, timings and more lights can be added to make a more interesting system. If you have done something similar please use the comments to discuss or link to it.    

Thank you to @SCC_Lancaster for the loan of a micro:bit.


Related Posts
Microbit and GlowBugs
CodeBug and Glowbugs 



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.

Monday 1 August 2016

Micro:bit and Glowbug


I saw on Twitter that some people have got the GlowBugs, more commonly used the CodeBugs (http://www.codebug.org.uk/learn/activity/73/glowbugs/), to work with the Micro:bit. Here is my go at doing it. I just wanted to get one GlowBug to flash Red, Green and Blue and keep cycling around.

The start point was to base it on the code from http://microbit-micropython.readthedocs.io/en/latest/neopixel.html for using Python with neopixels. The GlowBugs are essentially a single neopixel. So I connected the Data In to pin 0 and set the strip length to 1 ( np = neopixel.NeoPixel(pin0, 1) ) and then set the colours by setting np[0] to the colour wanted (eg. Red  np[0] = (255, 0, 0) ).


from microbit import *
import neopixel

# Setup the Neopixel strip on pin0 with a length of 1 pixel
np = neopixel.NeoPixel(pin0, 1)

while True:
    np[0] = (255, 0, 0)
    np.show()
    sleep(1000)
    np[0] = (0, 255, 0)
    np.show()
    sleep(1000)
    np[0] = (0 , 0 , 255)
    np.show()
    sleep(1000)


Video of it in action.




  


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.

Tuesday 12 April 2016

Dancing bot on a Microbit

In a earlier post on using micro:bit (Playing with microbit emulator-dancing bot)  a simple dancing robot image (using the 5x 5 grid was created). 
A dancing bot - 3x3 box for the body, with two legs. 

Thanks to a loan of a Micro:Bit from Lancaster University I can experiment with an actual micro:bit ( )











Experiment  1 - Using the buttons

So the functions for the idea were:


  • Button A - Move to the left and then back to the starting position;
  • Button B - Move to the right and then back to the starting position;
  • Buttons A+B - Jump up and then back to the starting position;
  • Shake - 'Crouches' and then back to the starting position



On the Microbit









Experiment 2- To add left and right tilting to it.
So if the micro:bit is tilted to the right the 'bot'  moves to the right, and the same for the left.

The tilting operation here is essentially - when the x on the accelerometer is less than zero move the 'bot' to the left and when it greater than zero go to the right.

Video showing it in action





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.

Monday 28 March 2016

Playing with the micro:bit Emulator - Dancing bot part 2

In a earlier post on using micro:bit (Playing with microbit emulator-dancing bot)  a simple dancing robot image (using the 5x 5 grid was created). In this post of modified version using the events to do pretty much the same thing (except the two button action)- A dancing bot - 3x3 box for the body, with two legs. 













So the functions for the idea were:

  • Button A - make it bob up and down;
  • Button B - makes it move to the left and right;




  • On shake - make it jump up and down.








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.

Top posts on this blog in March 2024

The Top 10 viewed post on this blog in March 2024. Covering areas such as small robots, augmented reality, Scratch programming, robots. Micr...