Thursday, 26 October 2017

Scratch SOL blog 1: 'Input, process, output'



 'Input, process, output'

This first lesson deals with the basic concepts of I,P,O and gets students to create a simple hardware quiz in Scratch 1.4. You will find all the resources below:

Resources:

Template :
https://github.com/ncscomputing/ScratchSOL2/raw/master/L1%20Pi%20quiz%20template.sb

Solution:
https://github.com/ncscomputing/ScratchSOL2/raw/master/L1%20pi%20quiz%20partial%20answer.sb

Instructions document:
https://github.com/ncscomputing/ScratchSOL2/raw/master/Coding%20Instructions%201.pdf

Example programming log:
https://github.com/ncscomputing/ScratchSOL2/raw/master/Programming%20Log%20example.docx

Teacher presentation:

https://github.com/ncscomputing/ScratchSOL2/raw/master/Lesson%201%20Content.pptx 

Below you can see an example of the quiz working and the code needed.

Output:


Code for Bear Sprite:


Enjoy:)

SOL: Visual coding with Scratch SOL all in one place



Over half term I have been putting together a SOL for year 7 at the the school that I work at. Below are the links to the resources that I have created thus far. I will continue to add more documentation and refinements over the coming 6 weeks. For now I have linked to the Scratch templates and solutions to the activity. Instructions and the slideshow will follow when complete along with a Socrative end of topic test.

Blog 1:  'L1: Input, process, output' Completed in full 
http://warksjammy.blogspot.co.uk/2017/10/scratch-sol-blog-1-l1-input-process.html

Blog 2:  'L2: Variables and conditionals and operators' Solution and template available
http://warksjammy.blogspot.co.uk/2017/10/scratch-sol-blog-2-variables-and.html



Blog 3: 'Big Red Button'
http://warksjammy.blogspot.com/2017/11/virtual-jam-blog-1-big-red-button.html


Blog 4:  'L4:Message passing' Solution and template available
http://warksjammy.blogspot.co.uk/2017/10/scratch-sol-blog-4-message-passing.html

Blog 5:  'L5: Lists' Solution and template available
http://warksjammy.blogspot.co.uk/2017/10/scratch-sol-blog-5.html

Blog 6:  'L6: 'EOT' (No resources yet)


If you like this blog check out all the others here


Sunday, 8 October 2017

EduBlocks blog 6: 1,2,3 coding cards



1,2,3 Coding cards

Over the last few weeks I have been experimenting with how to introduce Python to lower years in secondary school. Now everyone has used and seen the impact of the Scratch Cards on students. Here is my attempt to use the same idea with Python via EduBlocks.


The famous Scratch Cards.
1, 2, 3 coding cards demo

Here is the original demo version:


After evaluating them it was clear that more information needed to be added to make them more useful and intuitive. So for the crack I thought I would have a go at using markdown and creating a github friendly version of 2 of the three cards. With thanks to feedback from Les Pounder they evolved into these:

'Hello Steve'

'Whack the traffic lights on with Minecraft'

These are far more informative than version 1. But not that printable. So I have created a pdf'd version of each below so now they are easy to print off for use in the classroom and Jam's etc.

(NEW)Version 2 is now much clearer and more thorough and printer friendly :)

Edu Blocks sheet 1: Hello Steve


EduBlocks sheet 2: Turning on traffic lights with Minecraft. 




EduBlocks allows you to code in Python in a Scratchesk drag and drop easy to use interface. The key benefits of drag and drop Python is that it removes/ reduces the barriers of syntax errors by abstracting away some it and allowing you to focus on your instructions. The other great thing is that it also produces the textual version of the code so you can see what the actual code looks like minus all the rainbow blocks.


I have produced 3 introductory Minecraft and Python 1, 2, 3 coding cards to start with. Hopefully it will help encourage people to try and code the same hack in EduBlocks and then try the same hack in Python 3 and reinforce and ease the transition from drag and drop coding to text based coding.




Here are the first 3.



Enjoy :)

If you like this blog check out all the others here

Friday, 29 September 2017

Adventures with EduBlocks and Minecraft the collection

EduBlocks  

This summary of all the stuff that I have produced in the last year with edublocks:

EduBlocks on Raspberry Pi


Blog 1: EduBlocks getting started 

Blog 2: Amen to walking blocks

Blog 3: The Minecraft update, pixel art block demo
http://warksjammy.blogspot.co.uk/2017/05/edublocks-minecraft-update-pixelart.html

Blog 4: The Liverpool Makefest Minecraft Pixel art Twitter bot
http://warksjammy.blogspot.co.uk/2017/06/liverpool-makefest-minecraft-pixel-art.html

Blog 5: Graphing live data in Minecraft
http://warksjammy.blogspot.co.uk/2017/06/exabytes-17-workshops-v1.html

Blog 6: Bridging the gap between visual coding and text based coding with EduBlocks.
http://warksjammy.blogspot.co.uk/2017/10/edublocks-blog-6-123-coding-cards.html


NEW NEW
Edublocks : BitIO
'Hello Micro:bit, hello Minecraft'
link






EduBlocks for Micro:bit

Blog 1: Variables, Buttons and lists
link

Blog 2: For loops
link

Blog 3: Random Names
link

I will add more over time enjoy :)

If you like this blog check out all the others here

Wednesday, 13 September 2017

Micro:bit and the neo pixel strip / Codebug colour star

I have 5 codebug colour stars and one code bug. But I have access to many Micro:bits through work. Here is how to connect the codebug colour star to a MIcro:bit.

You will need:


  • A code bug colour star
  • 3 x jumper cables see below, fig 1
  • 3 x Crocodile clips see below, fig 2

fig 1

fig 2
 Instructions
1. Turn the colour star so you can see the pins on the back. Attach one jumper cable to the data in pin and then attach a crocodile cable see fig 2 to the jumper cable and attach to the Micro:bit pin 0.

2. Attach the second jumper cable to the GND pin on the colour star and then attach a crocodile cable see fig 2 to the jumper cable and attach to the Micro:bit GND pin.

2. Attach the third jumper cable to the 5V pin on the colour star and then attach a crocodile cable see fig 2 to the jumper cable and attach to the Micro:bit 3V pin.

3. Attach the Microbit to your PC/Pi Open MU micro python IDE.

4. Type in the following code:


from microbit import *
import neopixel
from random import randint


np = neopixel.NeoPixel(pin0,9)

while True:
    for pixel_id in range(0,len(np)):
        red = 255
        green = 0
        blue = 0
        
        np[pixel_id] = (red,green,blue)
        
        np.show()
        sleep(200)
        np.clear() 

5. Flash the code to the Micro:bit.
 
 This version is adapted from the MIcro:bit micropython website:
http://microbit-micropython.readthedocs.io/en/latest/neopixel.html

I have changed it to loop a red light around the neopixels. (See fig 3)
                                               

                                                      Fig 3

If you like this blog check out all the others here

BitIO blog 7: Minecraft CPU temperature monitor

BitIO blog 7: Minecraft CPU temperature monitor 



David Whale has been busy crafting more add on's to his BitIO library for the MIcro:bit. A few days ago he added the Micropython function to check the CPU temperature. His library can be accessed from here:





Here is the link to the code:


I have built / recycled Minecraft graphing code to create a CPU temperature monitor. Every time you press the a button it takes a temperature reading and then out puts this to Minecraft as a random coloured wool bar. Here is what you end up with:



Instructions:
1. Open python 3 on the Raspberry Pi.
2. Plug your Micro:bit into the Pi/PC.
3.   Ensure that you have read blog 1:
http://warksjammy.blogspot.co.uk/2017/07/blog-1-getting-started-with-bitio.html
and downloaded the BitIO master files from David Whales github

4. Go into the 'Bitio master' folder, find the 'src' folder 
5. Create a new Python 3 script.6. Call it "Minecraft CPU temperature monitor.py"
7. Type in the following code:

Code
import microbit
from mcpi import minecraft as minecraft
from mcpi import block as block
import time
import random

WoolList = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]

 
mc = minecraft.Minecraft.create()
 
orx,ory,orz = mc.player.getPos()

mc.postToChat("Start Graph")

TempBlock = 35,14

HumidityBlock = 35,3
Temperature_List = []#stores temp data

DataStreamCount= 0

def BuildDataBlockTemp(ImportedBlock):# take data for temp
    temp = int(microbit.temperature())
    Temperature_List.append(temp)
    orx,ory,orz = mc.player.getPos()

    for i in range (0,temp):
        x,y,z = mc.player.getPos()  
        mc.setBlock(x+30,i,z,35,ImportedBlock)
    mc.player.setPos(orx,ory,orz+1)
    msg = "Temp = {0}".format(temp)
    
    print(msg)
while True:
    
    time.sleep(0.25)
    if microbit.button_a.was_pressed():
        TempBlock = random.choice(WoolList)
        BuildDataBlockTemp(TempBlock) 

8. Open Minecraft, create a new world.
9. Run the code by pressing f5, checking for any errors that arise.
10. Press the a button on the Micro:bit.

Extension:
Try automating the graph so that it carries on every 10 seconds


You can now download a pdf version of these tutorials as part of the updated #hackpack resource booklet here:
https://github.com/ncscomputing/HpAnthologyV2/raw/master/Hackpack%20Anthology%20V2%200.3.pdf

If you like this blog check out all the others here

Monday, 11 September 2017

24 hours tracking the ISS in Minecraft and Twitter


During the last week or so I have been gradually tweaking my spin on Damien Mooney's ISS tracker. link https://damianmooney.wordpress.com/2016/02/16/raspberry-pi-minecraft-iss-tracker/

My bolt on is to take a screenshot record of each ISS movement and then tweet that picture from a twitter bot that I set up (@warksmessabout1).

This has worked for a while in trials, but has always fallen flat after a few hours. By trial and error I have hit upon a version which has run for 27 hours continuously updating 4 times an hour.

Here is an example screenshot of one of the recent updates from earlier today:




Here is the main twitter bot code:

"""
Tweeting ISS current position at set intervals with Minecraft Pi.
Get current ISS position from http://wheretheiss.at/ and map it on
a raspberry pi with minecraft
Damian Mooney wrote this minecraft Tracker in 2016. I have added a few
features on top, namely:
walking random wool blocks to mark current and positions
ability to screenshot the position using Martin O'Hanlons raspi2png tutorial:
(http://www.stuffaboutcode.com/2016/03/raspberry-pi-take-screenshot-of.html)
ability to tweet that using twython python library
"""
__author__ = '@damianmooney' #additions by @ncscomputing
from mcpi import minecraft as minecraft
from mcpi import block as block
from datetime import datetime
import time
import urllib2
import json
import random
import subprocess # to run shell script to autocall raspi2png
import sys
from twython import Twython
import BuildWorldDM as BuildWorld


consumer_key = ''
consumer_secret = ''
access_token = ''
access_token_secret = ''
       
api = Twython(consumer_key,consumer_secret,access_token,access_token_secret)

WoolList = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]

""" call where the iss at api thanks to Bill Shupp"""
def getiss():
    response = urllib2.urlopen('https://api.wheretheiss.at/v1/satellites/25544')
    mydata = response.read()
    return mydata

""" longitude: convert our longitude to a minecraft co-ordinate"""
def do_coord(longitude):
    mine_long = longitude * -.55
    return mine_long


#if __name__ == "__main__":


mc = minecraft.Minecraft.create()
mc.postToChat(" Minecraft ISS Tracker for @naascoderdojo")
mc.player.setting("autojump", False)
mc.player.setPos(6, 20, 50)
time.sleep(10)
while True:

    try:
        BuildWorld.Build()
        time.sleep(5)
        iss = getiss()
        pos = json.loads(iss)
        lat = pos['latitude']
        lon = pos['longitude']
        mc.postToChat("MC ISS tracker Version 1.4.1 of @naascoderdojo's Minecraft ISS Tracker")
        mc.camera.setFollow()
        mc.postToChat("Credits to @damianmooney")
        mc.postToChat(' ISS Location Lat: %.2f Long: %.2f' % (lat,lon))
        new_long = do_coord(lon)
        mc.player.setPos(int(new_long), 20, int(lat))
        mc.setBlock(int(new_long), 20-1, int(lat),35,random.choice(WoolList))
        msg = 'ISS pos '+'@SpacePiJam'+' lon %d lat %d' % (new_long, lat)
                    #print msg
        mc.postToChat(msg)
                    #ory to location that you havesaved raspi2png in
                    
        a=subprocess.check_output('./raspi2png -d 3 -p "myscreenshot.png"',shell=True)
        photo = open('myscreenshot.png', 'rb')
        time.sleep(8)
        api.update_status_with_media(status=msg, media=photo)
    except:
        mc.postToChat("update issue")
        a=subprocess.check_output('./raspi2png -d 3 -p "myscreenshot.png"',shell=True)
        photo = open('myscreenshot.png', 'rb')
        api.update_status_with_media(status="update issue", media=photo)

    time.sleep(450) # --only update once every 15 minutes


It reads in and renders the world text file from here:
https://raw.githubusercontent.com/ncscomputing/HpAnthologyV2/master/BuildWorldDM.py

The data file is here:
https://raw.githubusercontent.com/ncscomputing/HpAnthologyV2/master/world3.txt

Enjoy :)


If you like this blog check out all the others here