Skip to content

Instantly share code, notes, and snippets.

@topshed
topshed / Line following
Last active January 11, 2024 16:06
Line following
Here is one way to program a robot to follow a black line.
@topshed
topshed / Detecting Colour
Created January 11, 2024 15:41
Detecting Colour
using the colour sensor, you can detect a range of colours and how much light is reflected from an object
@topshed
topshed / LEGO self-driving robots at CoderDojo KU
Created January 11, 2024 14:50
LEGO self-driving robots at CoderDojo KU
The folowing gists may be useful, but feel free to just make things up yourself.
@topshed
topshed / Using the distance sensor
Last active January 11, 2024 14:33
LEGO Spike Prime snippets for CoderDojo
@topshed
topshed / LEGO Spike Prime for CoderDojo: Quick start
Last active January 11, 2024 15:55
LEGO Spike Prime for CoderDojo: Quick start
Start by building your robot.
The simplest robot is the Spike hub connected to two wheels and a caster
There are lots of ways to build a similar 2-wheeled bit, and the design shown here might not be the best for every task.
You may also need to adapt your code if you build a bot with larger motors or wheels.
@topshed
topshed / pumpkin_sh.py
Created November 2, 2022 13:37
pumpkin
# Import the libraries
from sense_hat import SenseHat
from time import sleep
# Set up the Sense HAT
sense = SenseHat()
sense.set_rotation(270, False)
# Set up the colour sensor
sense.color.gain = 60 # Set the sensitivity of the sensor
@topshed
topshed / dogcat.py
Created October 12, 2022 10:49
MZ 2022/23 animation eexample
# m8tricks output file
from sense_hat import SenseHat
from time import sleep
sh = SenseHat()
sh.rotation = 270
sh.clear(0,0,0)
g = (0,255,0)
y = (255,255,0)
b = (0,0,0)
p = (255,0,255)
@topshed
topshed / pir_example.md
Last active January 11, 2022 08:49
PIR example

Reading the value attribute from a gpiozero MotionSensor

This example shows how to use the .value attribute. Note that it is not a function and so does not use paranethseses. Here pir.value is treated in the same way as you would a variable.

from gpiozero import MotionSensor
from time import sleep

pir = MotionSensor(12)