Wednesday, 28 June 2017

EduBlocks blog 5: Exabytes 17 workshops v1

Here I will be adding the info for the two workshops:

 The potential of Edublocks to introduce Python to secondary students

Python 3 code:

from sense_emu import SenseHat
import mcpi.minecraft as minecraft
import mcpi.block as block
import time
import random


"""
NCS team Pixel Astro Pi competition entry

We have created a bar graph in minecraft and store the values for temp and
humidity in two seperate lists.


Team members are:
Archie
Tom
Adrian
"""

sense = SenseHat()

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
Humidity_List = []#stores humidity data

DataStreamCount= 0

def BuildDataBlockTemp(ImportedBlock):# take data for temp
    temp = int(sense.temp)
    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,ImportedBlock)
    mc.player.setPos(orx,ory,orz+1)
    msg = "Temp = {0}".format(temp)
    #sense.show_message(msg, scroll_speed=0.10 )
    print(msg)
    time.sleep(1)
def BuildDataBlockHumidity(ImportedBlock):# take data for humidity
    humidity = int(sense.humidity)
    Humidity_List.append(humidity)
    orx,ory,orz = mc.player.getPos()
    for i in range (0,humidity):
        x,y,z = mc.player.getPos()
        mc.setBlock(x+30,i,z,ImportedBlock)
    mc.player.setPos(orx,ory,orz+1)
    msg = "Humidity currently is: ",humidity
    print(msg)
    msg = "humidity = {0}".format(humidity)

    time.sleep(4)

 
while True:
    BuildDataBlockTemp(TempBlock) # 46
    BuildDataBlockHumidity(HumidityBlock)


EduBlocks code:





Picture of code working 




Around the world with Minecraft 

The code to carry out this workshop is taken from a recent blog post for Kano and recent Raspberry Jam at Coventry Library in May. You can access the code from here:

https://github.com/ncscomputing/Hackpack/blob/jams/May%20Jam%20resources.zip

I'll be polishing this off over the coming week.

Over :)

No comments:

Post a Comment