Skip to content

Instantly share code, notes, and snippets.

@kcranley1
kcranley1 / gpio-tkinterKC.py
Last active November 14, 2021 15:43
Tkinter GUI for GPIO control
# Tkinter and GPIO together Matt Richardson, modified by S&S 2-Apr-15
from Tkinter import *
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(23, GPIO.OUT)
GPIO.setup(24, GPIO.OUT)
GPIO.setup(25, GPIO.OUT)
GPIO.output(23, GPIO.LOW)
@kcranley1
kcranley1 / GPIOKC.py
Created April 1, 2015 15:02
Code copied directly from scotty3785 for a Python GUI for Raspberry Pi's GPIO pins
import sys
if(sys.version_info[0]<3):
from Tkinter import *
else:
from tkinter import *
import RPi.GPIO as pi
import math
#import tkSimpleDialog
@kcranley1
kcranley1 / KC6050ServoD.py
Last active August 29, 2015 14:13
This version uses the Complementary Filter output to drive the 2 servos
#!/usr/bin/python
# This version uses the Complementary Filter output to drive the 2 servos
import smbus
import math
import time
from Adafruit_PWM_Servo_Driver import PWM
# Initialise the PWM device using the default address
pwm = PWM(0x40)
@kcranley1
kcranley1 / KC6050ServoC.py
Last active August 29, 2015 14:12
Uses my implementation of the Complementary Filter
#!/usr/bin/python
# KC6050Servos.py Reads MPU6050 and also drives 2 servos
# Initially written by Adafruit and developed by S&S Dec 2014
import smbus
import math
import time
from Adafruit_PWM_Servo_Driver import PWM
@kcranley1
kcranley1 / KC6050ServoB.py
Created December 22, 2014 12:25
2 servos are controlled using the MPU6050
#!/usr/bin/python
# KC6050Servos.py Reads MPU6050 and also drives 2 servos
# Initially written by Adafruit and developed by S&S Dec 2014
import smbus
import math
import time
from Adafruit_PWM_Servo_Driver import PWM
#!/usr/bin/python
# KC6050Servos.py Reads MPU6050 and also drives 2 servos
# Initially written by Andrew Birkett and Adafruit and developed by S&S Dec 2014
import smbus
import math
import time
from Adafruit_PWM_Servo_Driver import PWM
#!/usr/bin/python
# KC6050Servos.py Reads MPU6050 and also drives 2 servos
import smbus
import math
from Adafruit_PWM_Servo_Driver import PWM
# Initialise the PWM device using the default address
pwm = PWM(0x40)
#!/usr/bin/python
import smbus
import math
# Power management registers
power_mgmt_1 = 0x6b
power_mgmt_2 = 0x6c
def read_byte(adr):
#!/usr/bin/python
#This python program serves a web page which can be accessed via
#local wifi network, giving x and y rotations of the MPU-6050
# Written by Andrew Birkett
# (http://blog.bitify.co.uk/2013/11/3d-opengl-visualisation-of-data-from.html)
# and modified by S&S Dec 2014
import web
import smbus
import math
#!/usr/bin/env python2.7
# script by Sparks N Smoke for SOFTWARE control of LEDs with Pulse Width Modulation
import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BCM)
GPIO.setup(24, GPIO.OUT) # LED Red PWM port - can use any GPIO port !
GPIO.setup(25, GPIO.OUT) # LED Green PWM port
GPIO.setup(26, GPIO.OUT) # LED Blue PWM port