Skip to content

Instantly share code, notes, and snippets.

View AnnaGerber's full-sized avatar

Anna Gerber AnnaGerber

View GitHub Profile
@AnnaGerber
AnnaGerber / 11_piezo.py
Last active October 16, 2022 13:51
PyFirmata code for Freetronics Experimenter's Kit
import pyfirmata
import math
board = pyfirmata.Arduino("/dev/ttyACM0")
# connect piezo to pin 9 to use PWM
SENSOR_PIN = 0
PIEZO_PIN = board.get_pin('d:9:p')
it = pyfirmata.util.Iterator(board)
int speakerPin = 9;
int played = 0;
int cicada_length = 331; // the number of notes
char cicada_notes[] = " 1212121212121212121212121211212 1212121212121212121212121211212 1212121212121212121212121211212 1212121212121212121212121211212 1212121212122121212121212122111 1212121212121212121212121211212 1212121212121212121212121211212 1212121212121212121212121211212 1212121212121212121212121211212 1212121212122121212121212122111 "; // a space represents a rest
int cicada_beats[] = {1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,2,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,2,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,2,1,1,1,1,1,1,

Building Wearables Session at CampJS

Programming ESP8266 with EspruinoJS

Getting set up

The boards are flashed with Espruino. Install the CP2102 driver and Espruino IDE from the Chrome extensions store. See Anna's blog for more details.

Use the GPIO pin numbers in the code e.g. pin 4 not D2.

@AnnaGerber
AnnaGerber / MotionSensor.json
Created June 12, 2017 12:18
Home automation with Raspberry Pi and Apple Home Kit - node-red flows
[
{
"id": "bb87c61.ab4c438",
"type": "homekit-service",
"z": "35c3d6b9.82903a",
"accessory": "dcd28ec5.c286d",
"name": "Door Motion Sensor",
"serviceName": "MotionSensor",
"x": 603.5,
"y": 202,
#include <Wire.h>
// pwm pins for red, green and blue
int rled = 9;
int gled = 10;
int bled = 11;
char currentColor = 'r';
/*
TODO: support hex values for rgb

Making an LED flower

Here's how to add an RGB LED to a silk flower

Use heat shrink tubing to insulate the leads on the LED. Use different colors of heatshrink so that you can identify the common lead later. image

Remove the green plastic core from a silk flower by pushing it out from the back image