This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from gpiozero import LED, Button | |
from time import sleep | |
red_led = LED(4) | |
yellow_led = LED(17) | |
blue_led = LED(23) | |
button = Button(25) | |
yellow_led.blink() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mcpi.minecraft import Minecraft | |
from gpiozero import LED | |
mc = Minecraft.create() | |
led = LED(4) | |
# blocks | |
redstone_ore = 73 | |
while True: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mcpi.minecraft import Minecraft | |
from time import sleep | |
from gpiozero import LED, Button | |
mc = Minecraft.create() | |
led = LED(4) | |
button = Button(25) | |
start = mc.player.getTilePos() | |
while True: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mcpi.minecraft import Minecraft | |
from time import sleep | |
from gpiozero import RGBLED | |
mc = Minecraft.create() | |
rgbled = RGBLED(26,19,13) | |
# block | |
grass = 2 | |
ice = 9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sense_hat import SenseHat | |
from time import sleep | |
sense = SenseHat() | |
sense.set_rotation(270) | |
sense.show_message("Hello from Coderdojo Banbridge!", 0.05) | |
r = (255,0,0) | |
g = (0,255,0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ephem | |
import time | |
iss = ephem.readtle("ISS (ZARYA)", | |
"1 25544U 98067A 17317.62840120 .00004117 00000-0 69389-4 0 9994", | |
"2 25544 51.6432 13.3344 0004461 113.6331 45.1344 15.54138509 84996") | |
while True: | |
iss.compute(ephem.now()) | |
print("Current position: %s, %s In darkness: %s" % (iss.sublat / ephem.degree, iss.sublong / ephem.degree, iss.eclipsed)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import io | |
import time | |
import picamera | |
from PIL import Image | |
from PIL import ImageStat | |
stream = io.BytesIO() | |
with picamera.PiCamera() as camera: | |
camera.start_preview() | |
time.sleep(2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import datetime as dt | |
from random import randint | |
from time import sleep | |
time_format = "%Y-%m-%d-%H-%M-%S" | |
with open('/home/pi/results.csv', 'w') as csvfile: # open the file for writing | |
fieldnames = ['time', 'lat', 'long', 'photo', 'lux'] # the different elements we store in each row | |
writer = csv.DictWriter(csvfile, fieldnames=fieldnames) # create writer with fields |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
from time import sleep | |
with open('/home/pi/results.csv') as csvfile: | |
fieldnames = ['time', 'lat', 'long', 'photo', 'lux'] # Same fields we wrote to the file | |
reader = csv.DictReader(csvfile, fieldnames=fieldnames) | |
next(reader) # this lets us skip the header row | |
for row in reader: | |
print(row['lux']) # here we are just interested in the lux column |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
time | lat | long | photo | lux | |
---|---|---|---|---|---|
2018-01-26-22-06-35 | 98 | 75 | photoloc | 199 | |
2018-01-26-22-06-40 | 14 | 90 | photoloc | 211 | |
2018-01-26-22-06-45 | 70 | 37 | photoloc | 59 | |
2018-01-26-22-06-50 | 73 | 75 | photoloc | 82 | |
2018-01-26-22-06-55 | 11 | 95 | photoloc | 219 | |
2018-01-26-22-07-00 | 12 | 61 | photoloc | 145 | |
2018-01-26-22-07-05 | 12 | 91 | photoloc | 274 | |
2018-01-26-22-07-10 | 39 | 49 | photoloc | 72 | |
2018-01-26-22-07-15 | 46 | 75 | photoloc | 199 |
OlderNewer