Exemplo n.º 1
0
def handle_rotation(tilt):
    GPIO.set_servo_pulsewidth(23, scale(tilt, (180.0, 0.0), (1000,2000)))
Exemplo n.º 2
0
def chat_connect():
    #Send to center positions when a new client connects
    GPIO.set_servo_pulsewidth(24, 1500)
    GPIO.set_servo_pulsewidth(23, 1500)
    print("New Client Connected")
Exemplo n.º 3
0
def handle_compass(compass):
    if (compass > 100.0) and (compass < 260.0):
        GPIO.set_servo_pulsewidth(24, scale(compass, (100.0, 260.0), (1050,1950)))
Exemplo n.º 4
0
import RPi.GPIO as GPIO
import pigpio
import time
import atexit
from time import sleep
from flask import Flask, render_template, request, send_from_directory
from flask_socketio import SocketIO
app = Flask(__name__)
socketio = SocketIO(app)

GPIO = pigpio.pi()
GPIO.set_servo_pulsewidth(23, 1500) # 
GPIO.set_servo_pulsewidth(24, 1300) # Center the servos


# Cleanup any open objects
def cleanup():
    print ("Cleaning up")
    GPIO.stop()

@socketio.on('connect')
def chat_connect():
    #Send to center positions when a new client connects
    GPIO.set_servo_pulsewidth(24, 1500)
    GPIO.set_servo_pulsewidth(23, 1500)
    print("New Client Connected")

@socketio.on('disconnect')
def chat_disconnect():
    print ("Client disconnected")