Monday, 17 April 2017

Blog 3: What can "UCreate" with a Micro:bit and Neo-pixels(Neon Axe)

Last summer I created some resources to use with Micro:bit/s for CPC and over the next few months and I will try and share the best bits with the kind permission of CPC. 

This one uses Micropython and a neopixel again. The neopixel is from this kit:

The picture below shows how the Micro:bit is set up, It has 7 neo-pixel lights sequentially connected with clips. P.s. and Lots of tape to hold it all down!

Micro:bit code originally from: here 


"""
    neopixel_random.py

    Repeatedly displays random colours onto the LED strip.
    This example requires a strip of 7 Neopixels (WS2812) connected to pin0.

"""
from microbit import *
import neopixel
from random import randint

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

while True:
    #Iterate over each LED in the strip

    for pixel_id in range(0, len(np)):
        red = randint(0, 60)
        green = randint(0, 60)
        blue = randint(0, 60)

        # Assign the current LED a random red, green and blue value between 0 and 60
        np[pixel_id] = (red, green, blue)

        # Display the current pixel data on the Neopixel strip
        np.show()

        sleep(100)



Have a go :)

Sunday, 16 April 2017

Blog 2: What can "UCreate" with a Micro:bit and Neo-pixels (Moody Storm Trooper).

Last summer I created some resources to use with Micro:bit/s for CPC and over the next few months and I will try and share the best bits with the kind permission of CPC. 

This second one uses Micropython and a neopixel again. The neopixel is from this kit:

The picture below shows how the Micro:bit is set up, this time it has an added Storm Trooper :) 

The code builds on from blog post 1: 

This version uses the temperature of the CPU to determine which face is displayed and which colour light the neo pixel shows. There are two versions which have different ranges of the conditions of the CPU. 
Version 1 code:
# Add your Python code here. E.g.
from microbit import *
import neopixel

np = neopixel.NeoPixel(pin0,1)

def Angry():
    np[0] = (255,0,0)#Red
    np.show()
    display.show(Image.ANGRY)
    sleep(3000)
    np.clear()
   
def Happy():
    np[0] = (0,255,0)#Green
    np.show()
    display.show(Image.HAPPY)
    sleep(3000)
    np.clear()
   
def Meh():
    np[0] = (255,69,0)#Yellow
    np.show()
    display.show(Image.MEH)
    sleep(3000)
    np.clear()
   
while True:
    temp  = temperature()
    if temp <= 27:#happy at body temp
        Happy()
    elif temp > 27 or temp <=29:#above body temp but ok
        Meh()#ok
    elif temp > 29 or temp <= 31:
        Angry()
    else:
        display.show(Image.SKULL)#


from microbit import *
import neopixel

np = neopixel.NeoPixel(pin0,1)

def Angry():
    np[0] = (255,0,0)#Red
    np.show()
    display.show(Image.ANGRY)
    sleep(3000)
    np.clear()
   
def Happy():
    np[0] = (0,255,0)#Green
    np.show()
    display.show(Image.HAPPY)
    sleep(3000)
    np.clear()
   
def Meh():
    np[0] = (255,69,0)#Yellow
    np.show()
    display.show(Image.MEH)
    sleep(3000)
    np.clear()
   
while True:
    temp  = temperature()
    if temp <= 25:#happy at body temp
        Meh()#ok / cool
    elif temp >= 25 or temp <=50:#above body temp but ok
        Happy()#ok / coo
    elif temp > 50 or temp <= 75:#super hot
        Angry()




Blog 1: What can "UCreate" with a Micro:Bit and Neo Pixels


Last summer I created some resources to use with Micro:bit/s for CPC and over the next few months and I will try and share the best bits with the kind permission of CPC. 

This first one uses Micropython and a neopixel. The neopixel is from this kit:

The picture below shows how the Micro:bit is set up:
  

The script shows 3 pictures on the led screen of happy, angry and meh(in between). Whilst doing this it also instructs the neo-pixel to light up red if angry, yellow if meh or green if happy. Why not have a go yourself.

Here is the code:


from microbit import *
import neopixel

np = neopixel.NeoPixel(pin0,1)

def Angry():
    np[0] = (255,0,0)#Red
    np.show()
    display.show(Image.ANGRY)
    sleep(3000)
    np.clear()
   
def Happy():
    np[0] = (0,255,0)#Green
    np.show()
    display.show(Image.HAPPY)
    sleep(3000)
    np.clear()
   
def Meh():
    np[0] = (255,69,0)#Yellow
    np.show()
    display.show(Image.MEH)
    sleep(3000)
    np.clear()
   
while True:
    Happy()
    Angry()
    Meh()

Sunday, 9 April 2017

The Tweeting Selfie Machine V1

About 5 hours ago I promised Rachel Lancaster that I would upgrade the CPC Minecraft selfie machine. The first upgrade comes with a GuiZero set of buttons. One to take the photo and one to tweet the selfie. You can see the refined version on the CPC area at Liverpool Makefest in June. Strike a blocky pose! :) 
 


Wednesday, 29 March 2017

#Hackpack resources and the community input

The #hackpack resources were created over the last few years by myself, Dan Aldred and Ben Davies. With other resources contributed from various others including Crazy Squeek and Elton Lane and . You can access it here:


My favourite and favourite at past RJams and when used in class has been "Forcefield" by Elton Lane. Page 60.

Ben Davies' Sonic Pi and Minecraft codes have always looked awesome but I have never had time to try out. That is changing at up coming Minecraft Raspberry Jam and Leamington Raspberry Jam. 

This would not have been as varied and rich in content without the community around the Raspberry Pi circuit. At last count it is over 200 pages long so it has lots of useful stuff in it KS 2/3 /4 appropriate.  Feel free to have a play :) 

P.s. credit where credit is due if I had not read about this half finished book by Craig Richardson then well this wouldn't exist :) 


Furthermore 50-60% of my ideas usually stem from something that I have seen here:


 
Enjoy!


Monday, 27 March 2017

Visualising Temperature data in a more inspiring way without hitting the wall


See your temperature reading as a random wool wall or a wool spire(the spire code is taken from Craig Richardson's Book which you can buy here:
https://www.amazon.co.uk/Learn-Program-Minecraft-Craig-Richardson/dp/1593276702


Here is the code for the wall and spire to work on both Sense hat and the Raspian emulator. Enjoy!


Sensehat temperature controlled spire:
https://raw.githubusercontent.com/ncscomputing/Hackpack/master/SenseHatSpireMCPI.py

Sensehat temperature controlled wall:
https://raw.githubusercontent.com/ncscomputing/Hackpack/master/SenseHatMCPIWALLV1.py

Sensehat emulator controlled wall:
https://raw.githubusercontent.com/ncscomputing/Hackpack/Volume-5/sense%20emu%20wall.py

Sense hat emulator controlled spire:
https://github.com/ncscomputing/Hackpack/blob/master/SenseHatSpireMCPI.py

Below you can see what they do using the emulator:

Sense hat emulator temperature controlled random coloured wall: 25 x 25 blocks:  

Sense hat emulator temperature controlled random coloured wall: 6 x 6 blocks:
Sense hat emulator temperature controlled random coloured Spire: 6 blocks:


Sense hat emulator temperature controlled random coloured Spire: 16 blocks:


Sunday, 26 March 2017

Rainbow Spiral using Minecraft Turtle from Martin O'Hanlon

For a while I have wanted a quick blast using Martin O'Hanlons Minecraft Turtle module. I've tweaked one of the examples a little bit to create a Rainbow Spiral. You can access Martins content here :

You can access the tweaked example here:

Here is what it creates:



You c