Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let R = 0
- let L = 0
- let RefR = 0
- let RefL = 0
- function adc1() {
- basic.showNumber(pins.analogReadPin(AnalogPin.P1))
- }
- input.onButtonPressed(Button.A, () => {
- adc1()
- })
- function adc2() {
- basic.showNumber(pins.analogReadPin(AnalogPin.P2))
- }
- input.onButtonPressed(Button.B, () => {
- adc2()
- })
- function Run() {
- while (true) {
- L = pins.analogReadPin(AnalogPin.P1)
- R = pins.analogReadPin(AnalogPin.P2)
- if (L > RefL && R > RefR) {
- iBIT.Motor(ibitMotor.Forward, 100)
- } else if (L < RefL && R > RefR) {
- iBIT.setMotor(ibitMotorCH.M1, ibitMotor.Forward, 20)
- iBIT.setMotor(ibitMotorCH.M2, ibitMotor.Forward, 80)
- } else if (L > RefL && R < RefR) {
- iBIT.setMotor(ibitMotorCH.M1, ibitMotor.Forward, 80)
- iBIT.setMotor(ibitMotorCH.M2, ibitMotor.Forward, 20)
- }
- }
- }
- input.onButtonPressed(Button.AB, () => {
- Run()
- })
- RefL = 150
- RefR = 120
Advertisement
Add Comment
Please, Sign In to add comment