PID example
This commit is contained in:
parent
dd5e1957d5
commit
f4b78c3ee7
16
docs/examples/line-follower-pid.md
Normal file
16
docs/examples/line-follower-pid.md
Normal file
@ -0,0 +1,16 @@
|
||||
|
||||
```blocks
|
||||
let lasterror = 0
|
||||
let D = 0
|
||||
let I = 0
|
||||
let P = 0
|
||||
let error = 0
|
||||
loops.forever(function () {
|
||||
error = sensors.color3.light(LightIntensityMode.Reflected) - 35
|
||||
P = error * 5
|
||||
I = I + error * 0.01
|
||||
D = (error - lasterror) * 0.2
|
||||
motors.largeBC.steer(P + (I + D), 100)
|
||||
lasterror = error
|
||||
})
|
||||
```
|
Loading…
Reference in New Issue
Block a user