Skip to content

Instantly share code, notes, and snippets.

@benrules2
benrules2 / fire.ino
Created December 11, 2017 03:33
Arduino Fireplace Code
// NeoPixel Ring simple sketch (c) 2013 Shae Erisson
// released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1
@benrules2
benrules2 / ThingShadow.ino
Last active April 3, 2021 22:19
Alexa Smart Home and Arduino Yun Smart Light Code
/*
* Copyright 2010-2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
@benrules2
benrules2 / haunted.sh
Created October 14, 2017 19:39
Play video file and flicker lights
omxplayer -b haunted.mp4&
python3.4 flicker.py 45
@benrules2
benrules2 / flicker.py
Last active September 29, 2019 00:48
Causes Philips Hue lights to flicker
from qhue import Bridge
import time
import random
import sys
bridge_ip = "<hue_ip_address>"
username = "<username>"
my_lights = [light_id_1, light_id_2]
def flicker(bridge, elapsed_time, lights_list = [], transition = 10):
<!DOCTYPE html>
<head>
<title>{{ title }}</title>
</head>
<body>
<h1>PLANT HELPLINE</h1>
<h2>The date and time on the server is: {{ time }}</h2>
<h2> {{ text }} </h2>
<a href="/auto/water/ON"><button>Turn ON Auto Watering</button></a>
import water
if __name__ == "__main__":
water.auto_water()
# External module imp
import RPi.GPIO as GPIO
import datetime
import time
init = False
GPIO.setmode(GPIO.BOARD) # Broadcom pin-numbering scheme
def get_last_watered():
@benrules2
benrules2 / plot_albums.py
Created August 19, 2017 14:37
Script to automatically generate a bar graph of album word duplicate rates
import matplotlib.pyplot as plt
from matplotlib import rcParams
def plot_album_ngrams(albums, artist):
pos = list(range(len(albums)))
width = 0.25
rcParams.update({'figure.autolayout': True})
fig, ax = plt.subplots(figsize=(12,6))
@benrules2
benrules2 / album_counter.py
Last active August 21, 2017 02:56
Main script file for counting duplicate sets of words in album lyrics
client_id = 'Your Genius Client ID'
client_secret = 'Your Genius Client Secret'
client_access_token = 'Your Genius Access Token'
import plot_albums
import string
import requests
import nltk
from sys import argv
from bs4 import BeautifulSoup
@benrules2
benrules2 / StarTracking.ino
Created June 6, 2017 11:43
Arduino code for star tracking
// Controls a threaded stepper motor to open levered board at same rate the earth spins
// for astrophotograph.
byte directionPin = 3;
byte stepPin = 2;
byte ledPin = 13;
float adjacent = 0.24;
float earth_rads_per_s = 0.00007272205;