from util.pinout import set_pinout from util.octopus import disp7_init from util.rgb import Rgb from time import sleep pinout = set_pinout() from hcsr04 import HCSR04 d7 = disp7_init() ws = Rgb(4) print("ulrasonic distance sensor") # servo1: 17, servo2: 16, 4 # t16 / e17 # Echo module echo = HCSR04(trigger_pin=pinout.PWM2_PIN, echo_pin=pinout.PWM1_PIN) while True: echo_cm = echo.distance_cm() d7.show(int(echo_cm)) if echo_cm > 15: ws.color((32, 0, 0)) print("---treshold---") else: ws.color((0, 32, 0)) print(echo_cm) sleep(0.5)
# The MIT License (MIT) # Copyright (c) 2020 Jan Cespivo, Jan Copak # octopusLAB pubsub example from time import sleep from examples.pubsub.ps_init import pubsub print("start: ps_rgb.py") from util.rgb import Rgb rgb = Rgb(15) # robot board default rgb.color((0, 0, 0)) while True: rgb.color((128, 0, 0)) pubsub.publish('value', 1) sleep(1) rgb.color((0, 128, 0)) pubsub.publish('value', 2) sleep(1) rgb.color((0, 0, 128)) pubsub.publish('value', 3) sleep(1)
print("this is simple Micropython example | ESP32 & octopusLAB") printOctopus() pinout = set_pinout() # set board pinout from util.io_config import get_from_file io_conf = get_from_file() led = Led(2) led.blink() ws = Rgb(pinout.WS_LED_PIN,io_conf.get('ws')) ws.simpleTest() d7 = disp7_init() # 7segment (8digit) display init def d7pause(ch = "-", sl = 0.5): for i in range(8): d7.show(" "*i + ch) sleep(sl) sleep(2) d7pause(sl=0.1) ws.rainbow_cycle() ws.color((0,0,0)) for i in range(9): d7.show(10-i) sleep(0.3) d7.show("")