Beispiel #1
0
from machine import Pin, Timer, PWM, SPI
from util.pinout import set_pinout
from time import sleep_ms
from random import randrange
from hcsr04 import HCSR04

pinout = set_pinout()

MAX_SPEED = 800
CRUISING_SPEED = 450
APPROACH_SPEED = 350
TURN_SPEED = 450
RANDOM_TURN_MIN = 600  # ms
RANDOM_TURN_MAX = 1000  # ms
COLLISION_THRESHOLD = 30  # cm
APPROACH_THRESHOLD = 100  #cm
MAX_SPEED_THRESHOLD = 250  #cm
LR_COMPENSATION = +10  # %, -10 slows L motor comared to R
ULTRASONIC_SAMPLING = 1000  # ms, how often detect obstacle

moto_L1 = Pin(pinout.MOTOR_1A, Pin.OUT)
moto_L2 = Pin(pinout.MOTOR_2A, Pin.OUT)
moto_L = PWM(Pin(pinout.MOTOR_12EN, Pin.OUT), freq=500, duty=0)

moto_R3 = Pin(pinout.MOTOR_3A, Pin.OUT)
moto_R4 = Pin(pinout.MOTOR_4A, Pin.OUT)
moto_R = PWM(Pin(pinout.MOTOR_34EN, Pin.OUT), freq=500, duty=0)

echo = HCSR04(trigger_pin=pinout.PWM2_PIN, echo_pin=pinout.PWM1_PIN)

Beispiel #2
0
# octopusLAB simple example
# ESP32board with "RGB WS LED"
# run: import examples.rgb_blink

from util.rgb import Rgb

# from util.octopus import led # short way

from util.pinout import set_pinout
pinout = set_pinout()  # set board pinout
from util.io_config import get_from_file
io_conf = get_from_file()

ws = Rgb(pinout.WS_LED_PIN, io_conf.get('ws'))

print("---examples/rgb_blink.py---")

# start main loop
while True:
    ws.simpleTest()
Beispiel #3
0
from micropython import const
from machine import Pin, I2C, TouchPad
from time import sleep_ms
from urandom import randint
from util.pinout import set_pinout
pinout = set_pinout()
#PCF address = 35 #33-0x21/35-0x23
ADDRESS = 0x20  #0x20(000) 0x23(100)
i2c_sda = Pin(pinout.I2C_SDA_PIN, Pin.IN, Pin.PULL_UP)
i2c_scl = Pin(pinout.I2C_SCL_PIN, Pin.OUT, Pin.PULL_UP)
i2c = I2C(scl=i2c_scl, sda=i2c_sda, freq=100000)
# 100kHz as Expander is slow
dice = (
    const(0b11101111),  #0; int = 239
    const(0b11100111),  #1; int = 231
    const(0b01101011),  #2; int = 107
    const(0b01100011),  #3; int = 99
    const(0b01011010),  #4; int = 90
    const(0b01000010),  #5; int = 66
    const(0b00011000)  #6; int = 24
)
# touchPin
t1 = TouchPad(Pin(4))
pin_led = Pin(2, Pin.OUT)

def controlCycle():
    autoGen = True
    generate = True
    buttonHeld = 0.0
    cycleTime = 0.0