Esempio n. 1
0
from nanpy import (ArduinoApi, SerialManager)
from time import sleep

connection = SerialManager()
a = ArduinoApi(connection=connection)

from nanpy import Servo

MIN_PULSE_LENGTH = 1000
MAX_PULSE_LENGTH = 2000
motA = Servo(4)
motA.attached()
motA.writeMicroseconds(0)
val = input("Enter your value: ")


def min_throttle():
    print("Sending minimum throttle")
    motA.writeMicroseconds(MIN_PULSE_LENGTH)


def max_throttle():
    print("Sending maximum throttle")
    motA.writeMicroseconds(MAX_PULSE_LENGTH)


def test_run():
    print("Running test in 3 \n")
    sleep(1)
    print(" 2\n")
    sleep(1)
Esempio n. 2
0
import math
import numpy as np
from nanpy.wire import Wire

connection = SerialManager()
a = ArduinoApi(connection=connection)
wire = Wire(connection=connection)

MIN_PULSE_LENGTH = 1000
MAX_PULSE_LENGTH = 2000
motA = Servo(0)
motB = Servo(0)
motC = Servo(0)
motD = Servo(0)

motA.attached()
motB.attached()
motC.attached()
motD.attached()

motA.writeMicroseconds(0)
motB.writeMicroseconds(0)
motC.writeMicroseconds(0)
motD.writeMicroseconds(0)

sleep(1)  # /*Give some delay, 7s, to have time to connect


def pid_loop(new_error_list):
    print("Error values :" + str(new_error_list))
    rad_to_deg = 180 / math.pi