Showing posts with label micropixel. Show all posts
Showing posts with label micropixel. Show all posts

Sunday 2 April 2017

Micro:bit, PXT, Micro:pixel and Rainbows

Continuing to play with PXT (http://pxt.microbit.org) and the Micro:bit, I wanted to try this in combination with a Proto-Pic Micro-pixel board with its 32 neopixel LEDs.

The routine (shown in the screenshot below) use the Neopixels package (use the add package option on the menu to add it) to do two things:

  • On pressing button B - cycle through the colours and shift the colour to the next pixel producing a shifting pattern.
  • On pressing button  A - the pixels are cleared one by one.

Code is shown above, and thank you to Jonathan "Peli" de Halleux (@pelikhan) for pointing out the redundant code I had left in, it is appreciated.

The video below shows the system in action:




You can try the code out in the simulator below:




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

Microbit + Micro:pixel reacting to music

This post discusses a simple way to get the Micropixel-Micro:Bit combination to change the Neopixels based on the music. Using the accelerometer on the Micro:Bit to provide x,y,z values to provide colour values for the neopixels; the micropixel sits over the speaker and vibrations are picked up. 

Simple but it roughly works (see the video at the end of the post).


Code
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=11
    rd=int(abs(accelerometer.get_x())/20)
    gr=int(abs(accelerometer.get_y())/20)
    bl=int(abs(accelerometer.get_z())/20)
    t1=10
    np[pxl] = (0, 0, bl)
    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()
    sleep(t1)
    np[pxl] = (0, 0, 0)
    np[pxl+1] = (0, 0, 0)
    np[pxl-1] = (0, 0, 0)
    np[pxl+2] = (0, 0, 0)
    np[pxl-2] = (0, 0, 0)


Video of it action using Revolve by cinematrix available under Creative Commons Licence (http://ccmixter.org/files/hisboyelroy/430 ).





Always obey the safety advice provided by Micro:bit https://microbit0.blob.core.windows.net/pub/jedfednb/Parent-and-Teacher-micro-bit-safety-guide.pdf 



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

ChatGPT, Data Scientist - fitting it a bit

This is a second post about using ChatGPT to do some data analysis. In the first looked at using it to some basic statistics  https://robots...