def __init__(self, numRatches): if numRatches < 1 or numRatches > 20: raise ValueError('Needs to be between 1 and 20') self.numRatches = numRatches self.ss = ServoSix() self.period = 0.7
def main(): args = parse_args() tweet_count = args.count if tweet_count == None or tweet_count == 0: tweet_count = DEFAULT_TWEET_COUNT config = {} with open('config.json') as config_file: config = json.load(config_file) print "----- Starting Up Tweet Sweets ------" ss = ServoSix() api = twitter.Api(consumer_key=config['ConsumerKey'], consumer_secret=config['ConsumerSecret'], access_token_key=config['AccessToken'], access_token_secret=config['AccessSecret']) all_statuses = api.GetUserTimeline(screen_name=config['UserName'], count=tweet_count) status_favorites = {} # Get initial status favorite counts for status in all_statuses: status_favorites[status.id] = status.favorite_count try: while (True): print "SCANNING TWEET FAVS..." for id, favs in status_favorites.iteritems(): current_status = api.GetStatus(id) if current_status.favorite_count > favs: print "New Favorite(s) Detected for {}".format(id) new_count = current_status.favorite_count - favs dispense_candy(new_count, ss) status_favorites[id] = current_status.favorite_count print "SLEEPING FOR 10 SECONDS..." time.sleep(10) finally: print "----- Shutting down Tweet Sweets ------"
import time from servosix import ServoSix ss = ServoSix() try: while True: servo = input("servo:") angle = input("angle:") ss.set_servo(servo, angle) finally: ss.cleanup()
from servosix import ServoSix import time ss = ServoSix() period = 2 def dispensePill(): ss.set_servo(1, 0) time.sleep(period) ss.set_servo(1, 180) class pillInfo(): pname = "NaN" pinfo = "NaN" dinfo = "NaN" pills = 0 def setinfo(self, pname, pinfo, dinfo, pills): self.pname = pname self.pinfo = pinfo self.dinfo = dinfo self.pills = int(pills) def getpills(self): return str(self.pills) def dispense(self): self.pills -= 1
import max7219.led as led from temp import * from servosix import ServoSix import time ss = ServoSix() device = led.matrix() device.orientation(180) min_temp, max_temp = 15, 45 min_servo, max_servo = 0, 180 def servoScale(val): temp_range = (max_temp - min_temp) servo_range = (max_servo - min_servo) servo_val = (((val - min_temp) * servo_range) / temp_range) + min_servo return servo_val while True: time.sleep(1) temp = temp_from_r(read_resistance()) device.show_message("{0:0.0f}".format(temp)) s = servoScale(temp) ss.set_servo(1, (180 - s)) print("{0:0.0f}".format(temp))
from servosix import ServoSix import time ss = ServoSix() period = 0.5 try: while (True): ss.set_servo(1, 0) time.sleep(period) ss.set_servo(1, 180) time.sleep(period) finally: ss.cleanup()
from servosix import ServoSix import time ss = ServoSix() ss.set_servo(1, 90) ss.set_servo(2, 90) ss.set_servo(3, 90) ss.set_servo(4, 90) time.sleep(1) print("Servos in 90 degree position") ss.cleanup()
from servosix import ServoSix import time import numpy as np import math import FaBo9Axis_MPU9250 import time import sys import datetime mpu9250 = FaBo9Axis_MPU9250.MPU9250() ss = ServoSix() i=0 while i <2: for j in range (80,110): ss.set_servo(1,j) time.sleep(0.05) for j in range (80,110): ss.set_servo(1,180-j) time.sleep(0.05) i+=1
def GUI(): #from voyeur import * import voyeur root = tk.Tk() # main window root.title("Team 1 - San Marcos") root.geometry("1270x650+0+0") label1 = Label(root, text="Security Camera") label1.grid(row=0, column=0, columnspan=4) button1 = Button(root, text="Camera On", width=22, command=lambda: voyeurPreviewON()) button1.grid(row=1, column=0, columnspan=4) button2 = Button(root, text="Camera Off", width=22, command=lambda: voyeurPreviewOFF()) button2.grid(row=2, column=0, columnspan=4) button3 = Button(root, text="Take a Photo", width=22, command=lambda: voyeurPicture()) button3.grid(row=3, column=0, columnspan=4) button4 = Button(root, text="Slideshow - Images Folder", width=22, command=lambda: slideShow()) button4.grid(row=4, column=0, columnspan=4) button5 = Button(root, text="Start Video Record", width=22, command=lambda: voyeurRecordON()) button5.grid(row=5, column=0, columnspan=4) button6 = Button(root, text="Stop Video Record", width=22, command=lambda: voyeurRecordOFF()) button6.grid(row=6, column=0, columnspan=4) button7 = Button(root, text="Play Last Recorded Video", width=22, command=lambda: playVid()) button7.grid(row=7, column=0, columnspan=4) button8 = Button(root, text=" 4:3 ", width=9, command=lambda: widescreen()) button8.grid(row=8, column=0, columnspan=2) button9 = Button(root, text=" 16:9 ", width=9, command=lambda: normal()) button9.grid(row=8, column=2, columnspan=2) button10 = Button(root, text="brightness +", width=9, command=lambda: voyeurBrightnessUP()) button10.grid(row=9, column=0, columnspan=2) button11 = Button(root, text="brightness -", width=9, command=lambda: voyeurBrightnessDOWN()) button11.grid(row=9, column=2, columnspan=2) button12 = Button(root, text="contrast +", width=9, command=lambda: voyeurContrastUP()) button12.grid(row=10, column=0, columnspan=2) button13 = Button(root, text="contrast -", width=9, command=lambda: voyeurContrastDOWN()) button13.grid(row=10, column=2, columnspan=2) button14 = Button(root, text="Exit", width=22, command=lambda: bye()) button14.grid(row=11, column=0, columnspan=4) label2 = Label(root, text="-------------------------------------------------") label2.grid(row=12, column=0, columnspan=4) ss = ServoSix() ss.set_servo(1, 90) ss.set_servo(2, 90) label3 = Label(root, text=" ") label3.grid(row=13, column=0, columnspan=4) button13_1 = Button(root, text="90 deg", width=3, command=lambda: rotate()) button13_1.grid(row=14, column=0) button19 = Button(root, text="Center", width=6, command=lambda: center(ss)) button19.grid(row=14, column=1, columnspan=2) button20 = Button(root, text="Pan", width=3, command=lambda: pan(ss)) button20.grid(row=14, column=3) label3 = Label(root, text="SERVO CONTROLS") label3.grid(row=13, column=1, columnspan=2) button13 = Button(root, text="UP", width=3, command=lambda: up(ss)) button13.grid(row=15, column=0) button14 = Button(root, text="DOWN", width=3, command=lambda: down(ss)) button14.grid(row=15, column=1) button15 = Button(root, text="LEFT", width=3, command=lambda: left(ss)) button15.grid(row=15, column=2) button16 = Button(root, text="RIGHT", width=3, command=lambda: right(ss)) button16.grid(row=15, column=3) label4 = Label(root, text="") label4.grid(row=16, column=1, columnspan=2) label5 = Label(root, text="Team Voyeur") label5.grid(row=17, column=1, columnspan=2) label6 = Label(root, text="") label6.grid(row=18, column=1, columnspan=2) label7 = Label(root, text="4398 SM Team #1") label7.grid(row=19, column=1, columnspan=2) label7 = Label(root, text="") label7.grid(row=20, column=1, columnspan=2) label7 = Label(root, text="<<< Authors >>>") label7.grid(row=21, column=1, columnspan=2) label8 = Label(root, text="Alvin Romualdo") label8.grid(row=22, column=1, columnspan=2) label9 = Label(root, text="Russell Bennight") label9.grid(row=23, column=1, columnspan=2) label10 = Label(root, text="Jordan Al Sahili") label10.grid(row=24, column=1, columnspan=2) label11 = Label(root, text="Maxwell Yi") label11.grid(row=25, column=1, columnspan=2) img = Image.open("/home/pi/Desktop/Under Construction/Spyguy") img = img.resize((200, 200), Image.ANTIALIAS) img = ImageTk.PhotoImage(img) panel = Label(root, image = img) panel.grid(row=17, column=0, columnspan=4) root.mainloop() # display the GUI voyeurPreviewOFF()
import time from servosix import ServoSix import sys ss = ServoSix() servo = int(sys.argv[1]) angle = int(sys.argv[2]) ss.set_servo(servo, angle)
class GongBerry: def __init__(self, numRatches): if numRatches < 1 or numRatches > 20: raise ValueError('Needs to be between 1 and 20') self.numRatches = numRatches self.ss = ServoSix() self.period = 0.7 def open(self): self.ss.set_servo(2, 170) time.sleep(self.period) self.ss.set_servo(1, 0) def close(self): self.ss.set_servo(2, 150) self.ss.set_servo(1, 90) def rat(self): self.ss.set_servo(2, 150) time.sleep(self.period) self.ss.set_servo(2, 50) time.sleep(self.period) def doit(self): try: self.close() for x in range(self.numRatches): self.rat() self.open() finally: self.ss.cleanup() time.sleep(1)
import requests import Adafruit_DHT import math import Adafruit_ADS1x15 import time import json import RPi.GPIO as GPIO import w1thermsensor from servosix import ServoSix from datetime import datetime API_ENDPOINT = "https://nc-greenhouse-project.herokuapp.com/greenhouse" ss = ServoSix() adc = Adafruit_ADS1x15.ADS1115() sensor1 = Adafruit_DHT.DHT22 GAIN = 1 # for pump switch PIN = 35 #for pump switch GPIO.setmode(GPIO.BOARD) GPIO.setwarnings(False) GPIO.setup(PIN, GPIO.OUT) GPIO.output(PIN, GPIO.HIGH) temp_inside_max = 28 sensor = w1thermsensor.W1ThermSensor() values = [0] * 100 def setup():
from servosix import ServoSix import time ss = ServoSix() period = 0.5 try: while True: ss.set_servo(1, 0) time.sleep(period) ss.set_servo(1, 180) time.sleep(period) finally: ss.cleanup()
import time from servosix import ServoSix import RPi.GPIO as GPIO PIR_PIN = 7 ss = ServoSix() GPIO.setmode(GPIO.BCM) GPIO.setup(PIR_PIN, GPIO.IN) recording = [[150, 85, 85, 10], [145, 85, 85, 10], [140, 85, 85, 10], [135, 85, 85, 10], [130, 85, 85, 10], [125, 85, 85, 10], [120, 85, 85, 10], [115, 85, 85, 10], [110, 85, 85, 10], [105, 85, 85, 10], [100, 85, 85, 10], [95, 85, 85, 10], [90, 85, 85, 10], [85, 85, 85, 10], [80, 85, 85, 10], [75, 85, 85, 10], [70, 85, 85, 10], [70, 85, 85, 10], [75, 85, 85, 10], [80, 85, 85, 10], [85, 85, 85, 10], [90, 85, 85, 10], [85, 85, 85, 10], [80, 85, 85, 10], [75, 85, 85, 10], [70, 85, 85, 10], [75, 85, 85, 10], [80, 85, 85, 10], [85, 85, 85, 10], [90, 85, 85, 10], [95, 85, 85, 10], [100, 85, 85, 10], [105, 85, 85, 10], [110, 85, 85, 10], [115, 85, 85, 10], [120, 85, 85, 10], [125, 85, 85, 10]] def playback(): print(recording) for x in range(0, len(recording) - 1): ss.set_servo(1, recording[x][0]) ss.set_servo(2, recording[x][1]) ss.set_servo(3, recording[x][2])
from servosix import ServoSix import time import numpy as np import math import FaBo9Axis_MPU9250 import time import sys mpu9250 = FaBo9Axis_MPU9250.MPU9250() import datetime ss = ServoSix() # a bunch of constants vGalRot = 220 pi = np.pi degs = 180.0 / pi rads = pi / 180.0 # London UCL LABLat = 51.525293 LABLong = -0.133674 now = datetime.datetime.utcnow() year = now.year month = now.month day = now.day hour = now.hour + now.minute / 60. def FNrange(x): b = x / 2. / pi
import time from servosix import ServoSix ss = ServoSix() recording = [[155, 85, 80, 30], [155, 90, 80, 40], [155, 95, 80, 55], [155, 100, 80, 65], [155, 105, 80, 75], [155, 100, 80, 65], [155, 95, 80, 50], [155, 90, 80, 40], [155, 85, 80, 30], [145, 85, 75, 30], [135, 85, 70, 30], [120, 85, 65, 30], [110, 85, 60, 30], [100, 85, 55, 30], [110, 85, 60, 30], [125, 85, 65, 30], [135, 85, 70, 30], [145, 85, 75, 30], [155, 85, 80, 30]] def playback(): print(recording) for x in range(0, len(recording)-1): ss.set_servo(1, recording[x][0]) ss.set_servo(2, recording[x][1]) ss.set_servo(3, recording[x][2]) ss.set_servo(4, recording[x][3]) time.sleep(0.05) try: while True: playback() except: ss.cleanup()
import max7219.led as led from temp import * from servosix import ServoSix import time ss = ServoSix() device = led.matrix() device.orientation(180) min_temp, max_temp = 15, 45 min_servo, max_servo = 0, 180 def servoScale(val): temp_range = (max_temp - min_temp) servo_range = (max_servo - min_servo) servo_val = (((val - min_temp)*servo_range) / temp_range) + min_servo return servo_val while True: time.sleep(1) temp = temp_from_r(read_resistance()) device.show_message("{0:0.0f}".format(temp)) s = servoScale(temp) ss.set_servo(1, (180-s)) print("{0:0.0f}".format(temp))