-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.rb
57 lines (47 loc) · 807 Bytes
/
main.rb
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
49
50
51
52
53
54
55
=begin
-----
motor control
-----
101011 forward
010111 reverse
0010x1 left
10001x right
011011 left rotate
100111 right rotate
111111 halt
xxxx00 freerun
-----
Turret control
-----
3.3V
@50Hz
5% -9% - 13%
min - user min - max
---add turret portion---
=end
cycle_time = 0.02
Duty_Cycle = 0.05 # max = 9%
def check
falsecount = 5
while falsecount > 4
delay_seconds = cycle_time
turret_movement(T1,T2)
end
end
def turret_movement(T1,T2)
if T1 == 1 && T2 == 0 # raise height
if Duty_Cycle >= 0.09
Duty_Cycle += 0.0025
end
end
if T1 == 0 && T2 == 1 # lower height
if Duty_Cycle <= 0.05
Duty_Cycle -= 0.0025
end
end
digital_writer = 14,HIGH
uSDelay = cycle_time*Duty_Cycle
delay_microseconds = uSDelay
digital_write = 14,LOW
delay_microseconds = cycle_time-uSDelay
end