Skip to content

Instantly share code, notes, and snippets.

@kcranley1
kcranley1 / drive_in_square.py
Last active August 29, 2015 13:57
My own version of drive_in_square.py
#! /usr/bin/env python
# drive_in_square.py
import time
import pibot
import sys
bot = pibot.PiBot()
# speed = 255
speed = 64
@kcranley1
kcranley1 / monitor_ultrasonic.py
Last active August 29, 2015 13:57
My version of monitor_ultrasonic.py
#! /usr/bin/env python
# monitor_ultrasonic.py
import time
import pibot
bot = pibot.PiBot()
while True:
@kcranley1
kcranley1 / robot_teleop.py
Last active August 29, 2015 13:57
My version of robot_teleop.py
#! /usr/bin/python
# robot_teleop.py
import pibot
import time
TURN_TIME = 0.2
bot = pibot.PiBot()
@kcranley1
kcranley1 / KCtest2.py
Last active August 29, 2015 13:57
My version of test_pibot_hardware.py - uses picamera to record video!
#! /usr/bin/env python
# test_pibot_hardware.py
import time
import os.path
import sys
import pygame
import pygame.mixer
@kcranley1
kcranley1 / KCtest1
Last active August 29, 2015 13:57
A version of test_pibot_hardware.py - under construction!. Hoping to develop it to use the ultrasonic distance detector to stay out of trouble!
#! /usr/bin/env python
# KCtest1.py
import time
import os.path
import sys
import pygame
import pygame.mixer
@kcranley1
kcranley1 / KCTest3.py
Last active August 29, 2015 13:57
This version uses picamera to record video!
#! /usr/bin/env python
# KCtest3.py - Records a video using picamera
import time
import os.path
import sys
import pygame
import pygame.mixer
@kcranley1
kcranley1 / KCtest4.py
Last active August 29, 2015 13:58
A further version to modify the routine to get out of trouble
#! /usr/bin/env python
# KCtest4.py - All references to picamera have been removed, to allow
# MJPG-Streamer to be used to transmit JPEG images over WiFi network
import time
import os.path
import sys
import pygame
#!/usr/bin/env python2.7
# script by Sparks N Smoke based on Alex Eames at http://RasPi.tv
import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BCM)
GPIO.setup(20, GPIO.IN, pull_up_down = GPIO.PUD_UP) # Button 0
GPIO.setup(21, GPIO.IN, pull_up_down = GPIO.PUD_UP) # Button 1
GPIO.setup(22, GPIO.IN, pull_up_down = GPIO.PUD_UP) # Button 2
#!/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
#!/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