100 Top Tips: Microsoft Excel
Power up your Microsoft Excel skills with this powerful pocket-sized book of tips that will save you time and help you learn more from your spreadsheets.
23 February 2018
In education, it provides a highly visual way to explore nested loops and nested lists. It's also a good way to drill your soldering skills, since it comes in kit form.
You can read my review of it in issue 67 of The MagPi, which has just been published. It's available for free download, but you can support the Raspberry Pi Foundation by buying it, on the high street or by subscription.
Here's a video showing the PiCube in action:
And here's the code I wrote for that demo. PiCube comes with some demo programs, but the pin numbers were arranged in a linear list in them. I found it easier to work my way around the grid when I created a nested list for the pins, which I've called GRID_3D here.
#! /usr/bin/python
import RPi.GPIO as GPIO
import time
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
LAYER = [40,38,36,32]
GRID_3D = [[7, 11, 35, 37],
[12, 13, 31, 33],
[15, 16, 23, 29],
[18, 19, 21, 22]
]
def enable_layer(layer):
GPIO.output(LAYER[layer], True)
def disable_layer(layer):
GPIO.output(LAYER[layer], False)
def light_on(y, x, z):
enable_layer(y)
GPIO.output(GRID_3D[x][z], True)
def light_off(y, x, z):
enable_layer(y)
GPIO.output(GRID_3D[x][z], False)
def reset():
for x in range(4):
for z in range(4):
GPIO.output(GRID_3D[x][z], False)
time.sleep(0.1)
def resetlayer():
for i in range(0,4):
GPIO.output(LAYER[i],False)
for pin in LAYER:
GPIO.setup(pin, GPIO.OUT)
for x in range(4):
for z in range(4):
GPIO.setup(GRID_3D[x][z], GPIO.OUT)
reset()
resetlayer()
# Display each light in turn
for y in range(4):
for x in range(4):
for z in range(4):
light_on(y, x, z)
time.sleep(0.1)
light_off(y, x, z)
disable_layer(y)
#Turn on all the lights
for y in range(4):
enable_layer(y)
for x in range(4):
for z in range(4):
light_on(y, x, z)
time.sleep(0.25)
PiCube is available now from SB Components.
Permanent link for this post | Blog Home | Website Home | Email feedback
© Sean McManus. All rights reserved.
Visit www.sean.co.uk for free chapters from Sean's coding books (including Mission Python, Scratch Programming in Easy Steps and Coder Academy) and more!
Power up your Microsoft Excel skills with this powerful pocket-sized book of tips that will save you time and help you learn more from your spreadsheets.
This book, now fully updated for Scratch 3, will take you from the basics of the Scratch language into the depths of its more advanced features. A great way to start programming.
Code a space adventure game in this Python programming book published by No Starch Press.
Discover how to make 3D games, create mazes, build a drum machine, make a game with cartoon animals and more!
Set up your Raspberry Pi, then learn how to use the Linux command line, Scratch, Python, Sonic Pi, Minecraft and electronics projects with it.
In this entertaining techno-thriller, Sean McManus takes a slice through the music industry: from the boardroom to the stage; from the studio to the record fair.