Skip to content

Instantly share code, notes, and snippets.

'''
Five-Button Melody Recorder with Raspberry Pi
2015 Amanda on wordpress.electrothoughts.com
Please reuse this code to your heart's content!
This circuit records a melody using buttons and plays the melody
back through a buzzer or 8 ohm speaker. Inspired by the game 'Music Machine'
on old electronic Merlin toy.
Components:
@mandyRae
mandyRae / complex_quadratic_formula_calculator.py
Created November 18, 2015 13:32
This Python 3 program uses the quadratic formula to solve a quadratic equation. The user enters values for a, b, and c.
'''
Quadratic Equation Calculator
*Displays the equation
*Computes two real and complex solutions to standard quadratic equations
*Provides clean output
Amanda @ Electrothoughts.wordpress.com Oct 2015
Please reuse this code to your heart's content!
'''
@mandyRae
mandyRae / iopi.py
Last active December 1, 2015 14:11
This is a super simple Python module that's used for quicker access to the GPIO pins on the Raspberry Pi, mainly for use in interactive mode.
"""
iopi module ... Input/Output Pi Version 0.0
For instructions on how to install this module on
Raspberry Pi, visit https://electrothoughts.wordpress.com/2015/06/23/the-python-raspi-gpio-module-remade-iopi-py/
This is a module to simplify use of GPIO pins,
including faster setup and control
especially within interpreter/IDLE
"""
'''
PROTOTYPE SOFTWARE -- Drum Kit with Raspberry Pi
Amanda @ electrothoughts.wordpress.com 2015
Please reuse this code to your heart's content!
Notes:
- Uses pygame.mixer module to play audio files
- Uses indexing for all functions with drums and LEDs
- Some extraneous functions, such as the extra colors in pinColor
- This will run headless, so eventually the KeyboardInterrupt will be removed
@mandyRae
mandyRae / oscillating_air-conditioning_fan_arduino.ino
Last active January 18, 2016 00:26
This is software for an Arduino-controlled oscillating air-conditioning fan. A fan, two potentiometers, and a servo are wired up to the Arduino. The fan is mounted to the servo, and can move in a 90 degree sweep. One pot adjusts the fan's speed, and the other adjusts the oscillation speed.
/*
Oscillating Fan with Arduino Uno -- Software
Find build instructions at www.electrothoughts.wordpress.com/2015/05/31/oscillating-fan-with-arduino-part-2/
Also see "Part 1" of this project for initial ideas at www.electrothoughts.wordpress.com/2015/05/21/oscillating-fan-with-arduino-part-1/
Amanda on Electrothoughts - 2015
Reuse this code to your heart's desire!
Components Required:
-5v micro-servo
@mandyRae
mandyRae / probability_dice_sim.py
Created February 9, 2016 17:11
Dice rolling simulation to compare the number experiemental trials vs theoretical probability
'''
Experimental Probability Dice Simulator
This program serves to demonstrate how experimental probability gives
way to theoretical probability as the number of trials increases, using rolls
of a perfect, standard, cube-shaped die. In effect, it demonstrates that the
probability of rolling any number on a perfect die is:
lim x = 1/6 = 0.1666...
x -> infty
@mandyRae
mandyRae / sonar.ino
Created February 14, 2016 01:48
Sample sketch for using ultrasonic sensors with Arduino
//This sketch demonstrates how to interface with ultrasonic sensors using the Arduino and NewPing library
#include <NewPing.h>
int TRIGGER = 12;
int ECHO = 11;
//Declare a sonar object specifying the trigger and echo pins
NewPing sonar(TRIGGER, ECHO);
@mandyRae
mandyRae / pi.py
Created March 15, 2016 12:26
Happy Pi Day!!!!
import time
j = 0
pi = 0
plusminus = True
start_time = time.time()
while True:
if j%2 == 1:
if plusminus == True:
pi += (1/j)
@mandyRae
mandyRae / relaylight.ino
Last active April 2, 2016 20:41
ultrasonic sensor and power relay to control desk lighting
/*
Using an Arduino with a Power Relay
Parts used:
--ultrasonic sensor
--desk lamp
--Arduino Uno
--120v relay
'''
Large Seven-Segment Display
Python Code for controlling display with a Raspberry Pi's GPIO
Written by Amanda on electrothoughts.wordpress.com, Aug 25, 2015
Modify this code to your heart's content!
This code contains function definitions. To make your display work,
it's recommended that you run the code in the Python shell IDE as root, and execute
functions from there, for example enter the following in a terminal: