Skip to content

Instantly share code, notes, and snippets.

View bmidgley's full-sized avatar

Brad Midgley bmidgley

  • Utah
  • 13:32 (UTC -06:00)
View GitHub Profile
#include "SSD1306.h"
// Sketch->Include Library->Manage libraries
// ESP8266 and ESP32 Oled Driver for SSD1306 display by Daniel Eichhorn, Fabrice Weinberg
// https://github.com/squix78/esp8266-oled-ssd1306
SSD1306 display(0x3c,5,4);
void setup() {
Serial.begin(115200);
#include <Servo.h>
Servo myservo; // create servo object to control a servo
// twelve servo objects can be created on most boards
int pos = 0; // variable to store the servo position
void setup() {
myservo.attach(13); // attaches the servo on pin 9 to the servo object
@bmidgley
bmidgley / motion.py
Created November 29, 2017 03:12
Monitor a raspberry pi motion sensor via mqtt
#!/usr/bin/env python3
import RPi.GPIO as GPIO
import time
import os
import sys
import threading
import paho.mqtt.publish as publish
@bmidgley
bmidgley / wet.ino
Created February 18, 2018 18:33
esp8266 moisture detector v1
/* wetness sensor v1
* active buzzer is connected to D1
* sensor is connected to A0
* temp sensor is connected to D3
* lolin nodemcu uses D4 for its LED
*/
#include <ESP8266WiFi.h>
#define THRESHHOLD 20
@bmidgley
bmidgley / Pixel.ino
Last active February 19, 2018 16:24
Lightblue bean neopixel ring animated
#include <Adafruit_NeoPixel.h>
// The pin that is connected to the NeoPixels
#define PIN 5
// The amount of LEDs in the NeoPixels
#define NUMPIXELS 16
// previousLedColor will be used to check if the LED's color has changed
LedReading previousLedColor;
// Connect the gy-521 accelerometer to a digispark attyiny85 and light an LED when tipping it to the side (along X)
// Wire this up with gy-521:attiny85 as vcc:5v, gnd:gnd, sda:p0, scl:p3; sda and scl each have a 4.7k pull-up resistor
#include <TinyWireM.h>
const int MPU_addr=0x68; // I2C address of the MPU-6050
int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;
void mpu_init() {
TinyWireM.beginTransmission(MPU_addr);
@bmidgley
bmidgley / shiny.ino
Created May 2, 2018 13:27
Read the accelerometer and use addressible lights on an attiny85
#include <TinyWireM.h>
#include <FastLED.h>
const int MPU_addr=0x68; // I2C address of the MPU-6050
int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;
boolean was_turned = false;
#define NUM_LEDS 15
@bmidgley
bmidgley / car.py
Created June 28, 2018 22:02
bluetooth python car
#!/usr/bin/env python
# sudo apt-get install bluez python-gobject
# hcitool scan
# echo 1234 | bluez-simple-agent hci0 00:12:05:09:90:51
# bluez-test-device trusted 00:12:05:09:90:51 yes
import socket
import time
//!OpenSCAD
// 2018-10-08 modified the "microbit diffuser" below to make the pixels more distinct -Brad
// The Microbit is a cool new thing from the BBC.
// It runs micropython.
// I wrote a flame simulator on it and this panel fits on top
// So you can adjust the parameters with the buttons and// see a diffuse fire display through the plastic shell
#!/usr/bin/env ruby
require 'getoptlong'
require 'tty/tree'
opts = GetoptLong.new(
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
[ '--brief', '-b', GetoptLong::NO_ARGUMENT ],
)
verbose = true