-
Notifications
You must be signed in to change notification settings - Fork 0
/
H-bro_test.py
48 lines (35 loc) · 1.01 KB
/
H-bro_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from machine import Timer
from time import sleep
from lib.car import Car
tim1 = Timer(1)
bil = Car()
# noinspection PyUnusedLocal
def tick(timer):
print("L enc:", bil._leftMotor.encValue(), "R enc:", bil._rightMotor.encValue(), 3000 )
try:
#tim1.init(freq=1, mode=Timer.PERIODIC, callback=tick )
def foo( du, ff, rr ):
print("duty:", du/32000, "FF", ff, "RR", rr)
bil._leftMotor.PWMPin.duty_u16( 65535 )
bil._leftMotor.forwardPin.value( 1 )
bil._leftMotor.reversePin.value( 0 )
sleep(2)
bil._leftMotor.PWMPin.duty_u16( du * 65535 )
bil._leftMotor.forwardPin.value( ff )
bil._leftMotor.reversePin.value( rr )
sleep(4)
bil.set_hastighed(100)
foo(0,0,0)
foo(0,0,1)
foo(0,1,0)
foo(0,1,1)
foo(1,0,0)
foo(1,1,1)
bil.coast()
sleep(4)
#while True:
#pass
finally:
tim1.deinit()
bil.deinit()
print("shut down")