KRITSADA

Test Board IBIT

Jan 16th, 2019
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. input.onButtonPressed(Button.A, function () {
  2.     iBIT.Motor(ibitMotor.Forward, 100)
  3. })
  4. input.onButtonPressed(Button.B, function () {
  5.     iBIT.Motor(ibitMotor.Backward, 100)
  6. })
  7. input.onButtonPressed(Button.AB, function () {
  8.     iBIT.MotorStop()
  9. })
  10. input.onGesture(Gesture.TiltLeft, function () {
  11.     iBIT.Servo(ibitServo.SV1, 0)
  12.     iBIT.Servo(ibitServo.SV2, 0)
  13. })
  14. serial.redirectToUSB()
  15. basic.pause(1000)
  16. basic.forever(function () {
  17.     serial.writeNumber(iBIT.ReadADC(ibitReadADC.ADC0))
  18.     serial.writeString("  ")
  19.     serial.writeNumber(iBIT.ReadADC(ibitReadADC.ADC1))
  20.     serial.writeString("  ")
  21.     serial.writeNumber(iBIT.ReadADC(ibitReadADC.ADC2))
  22.     serial.writeString("  ")
  23.     serial.writeNumber(iBIT.ReadADC(ibitReadADC.ADC3))
  24.     serial.writeString("  ")
  25.     serial.writeNumber(iBIT.ReadADC(ibitReadADC.ADC4))
  26.     serial.writeString("  ")
  27.     serial.writeNumber(iBIT.ReadADC(ibitReadADC.ADC5))
  28.     serial.writeString("  ")
  29.     serial.writeNumber(iBIT.ReadADC(ibitReadADC.ADC6))
  30.     serial.writeString("  ")
  31.     serial.writeNumber(iBIT.ReadADC(ibitReadADC.ADC7))
  32.     serial.writeLine("")
  33.     if (pins.digitalReadPin(DigitalPin.P0) == 1) {
  34.         led.plot(0, 2)
  35.     } else {
  36.         led.unplot(0, 2)
  37.     }
  38.     if (pins.digitalReadPin(DigitalPin.P1) == 1) {
  39.         led.plot(0, 3)
  40.     } else {
  41.         led.unplot(0, 3)
  42.     }
  43.     if (pins.digitalReadPin(DigitalPin.P2) == 1) {
  44.         led.plot(0, 4)
  45.     } else {
  46.         led.unplot(0, 4)
  47.     }
  48.     pins.digitalWritePin(DigitalPin.P19, 0)
  49.     if (pins.digitalReadPin(DigitalPin.P19) == 1) {
  50.         led.plot(3, 3)
  51.     } else {
  52.         led.unplot(3, 3)
  53.     }
  54.     pins.setPull(DigitalPin.P19, PinPullMode.PullUp)
  55.     pins.digitalWritePin(DigitalPin.P20, 0)
  56.     if (pins.digitalReadPin(DigitalPin.P20) == 1) {
  57.         led.plot(4, 3)
  58.     } else {
  59.         led.unplot(4, 3)
  60.     }
  61.     pins.setPull(DigitalPin.P20, PinPullMode.PullUp)
  62. })
  63. control.inBackground(function () {
  64.     while (true) {
  65.         iBIT.Servo(ibitServo.SV1, 180)
  66.         iBIT.Servo(ibitServo.SV2, 180)
  67.         basic.pause(1200)
  68.         iBIT.Servo(ibitServo.SV1, 0)
  69.         iBIT.Servo(ibitServo.SV2, 0)
  70.         basic.pause(1200)
  71.     }
  72. })
Advertisement
Add Comment
Please, Sign In to add comment