Skip to content

Instantly share code, notes, and snippets.

Note that I spoke to the creator of this project who said that they were a few bugs in the original code as published. This gist uses the updated, fixed code.

What's needed

A Pi with Minecraft installed

How would the participants interact?

There should be a Minecraft window open and an editor with the almost-complete code alongside. There should be two tabs open in the editor.

@topshed
topshed / environsensehat_readme.md
Last active November 1, 2018 14:18
Environmental sensing with SenseHAT

Environmental sensing with SenseHAT

What's needed?

A Pi and SenseHAT

Two options. Both really rely on the SenseHAT being somewhat accessible so that participants can actually change the environment. Ideally the PI and SenseHAT would be on the table (perhaps in a 3d printed flight case with with cables glued in to secure it?). Alternatively, there could be a hole cut in perspex screen so that participants can blow on the SenseHAT (to change humidity and temperature).

Option 1: simple bar graph displayed on SenseHAT LED matrix.

@topshed
topshed / Solar Power Pi - TPL5110 method.md
Last active July 25, 2022 18:30
Solar Power Pi - TPL5110

Equipment

  • Powerbosst 500
  • Pimoroni LipoShim
  • Adafruit TPL5110

Imgur

Process

  • Resistor on TPL5110 DELAY pin sets period (120K = 1 hour)
@topshed
topshed / Solar Power Pi - Arduino method.md
Last active September 25, 2018 17:00
Solar Power Pi - Arduino method.md

Equipment

  • RTC
  • Powerbosst 500
  • Pimoroni LipoShim
  • Arduino Trinket

Imgur

Process

@topshed
topshed / snippet.md
Last active August 21, 2018 13:37
Raspbian bash script for wifi network switching if Internet drops
#!/bin/bash
# Checks for Internet connectivity and changes to an alternative wifi network if
# it detects a problem.
# Needs to have a wpa_supplicant file for each network:
#  wpa_supplicant_1 for SSID! and wpa_supplicant_2 for SSID2
# Can easily be extended to more than 2 possible networks

# function to bring down wireless interface, stop wpa_supplicant service and
# then bring up wlan0 again

Introduction to Arduino

Types of Arduino

Just like Raspberry Pi, Arduino both the open of a computer company and their project: a single-board microcontrollers and microcontroller for building digital devices and interactive objects that can sense and control objects in the physical and digital world. The project's products are distributed as open-source hardware and software, which are licensed under licenses that allow anyone to manufacture of Arduino boards.

There are lots of dirrent types of Arduino. Many are based around the ATMega328 chip, although there are now lots of other varieties in use.

Official Arduino/Genuino models come in a range of sizes. from left to right: Leonardo, Uno, MKR Zero and Micro.

Ultrasonic Range Finder

This circuit demonstrates how to use an HC-SR04 Ultrasonic Range finder to measure the distance to an object.

Imgur

The HC-SR04 ultrasonic sensor uses sonar to determine distance to an object like bats or dolphins do. Power the module using Vcc, ground it using GND, and use an Arduino digital pin to send an input signal to TRIG, which triggers the sensor to transmit an ultrasonic burst of 8 x 40KHz pulses. The sound waves bounce off any nearby objects and some are reflected back to the sensor.

The ECHO pin will be “LOW” (0V) until the outgoing signal has stopped, at which point it goes HIGH (5v). Once a return pulse has been detected, ECHO is set “LOW” again. So the time for which the ECHO pin is HIGH equals the time taken for the sound wave to travel to the nearest obstacle and back.

Analog temperature sensor

This circuit demonstrates how to read the analog input from a TMP36 temperature sensor. This corresponds to the temperature measured by the sensor.

Imgur

The Arduino will give you a reading that you need to convert into temperature value. Because the TMP36 is connected to 5v we need to multiply the reading from the analog pin by 5. Then divide by 1024 (the Arduino uses a 10-bit analog to digital converter - this means that it will map input voltages between 0 and 5 volts into integer values between 0 and 1023).

Once you have a voltage reading, convert that to temperature: for the TMP36 there are 10 mv per degree, with a 500 mV offset

Analog inputs

Analog electronics have a continuously variable signal, in contrast to digital electronics where signals usually take only two levels (HIGH/LOW or 1/0).

This circuit demonstrates how to read an analog input - the voltage across a variable resistor - and uses this to control the tone of a buzzer.

Imgur   Imgur