Skip to content

Instantly share code, notes, and snippets.

@boukeas
boukeas / tcs34725.md
Last active March 29, 2022 10:56
Light and Colour sensor on the mkII Astro Pi

Light and colour sensor on the mkII Astro Pi

The mkII Astro Pi Flight Units carry a custom Sense HAT that includes a TCS34725 colour sensor, capable of measuring the amount of Red, Green and Blue (RGB) in the incident light, as well as providing a Clear light (brightness) reading.

To support interaction with this sensor, the Flight OS includes a custom-built sense_hat Python library. The SenseHat class provides a colour (or color) attribute which corresponds to a ColourSensor object and provides access to the colour sensor.

The example below serves as an overview of how the colour sensor can be used, while the sections that follow provide additional details and explanations.

from sense_hat import SenseHat
@boukeas
boukeas / morse.py
Created February 28, 2017 16:32
A Morse Code signaler for the Raspberry Pi
from gpiozero import LED
from time import sleep
# morse code dict
morse = {
'a': '._',
'b': '_...',
'c': '_._.',
'd': '_..',
'e': '.',