KRITSADA

Radio iBit Robot Remote Control

Sep 6th, 2018
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. input.onGesture(Gesture.LogoUp, () => {
  2.     radio.sendNumber(7)
  3.     basic.showLeds(`
  4.         # # # # #
  5.         # # # # #
  6.         . . . . .
  7.         . . . . .
  8.         . . . . .
  9.         `)
  10. })
  11. input.onButtonPressed(Button.A, () => {
  12.     radio.sendNumber(1)
  13.     basic.showLeds(`
  14.         . . . . .
  15.         # # . . .
  16.         # # . . .
  17.         . . . . .
  18.         . . . . .
  19.         `)
  20. })
  21. input.onButtonPressed(Button.AB, () => {
  22.     radio.sendNumber(3)
  23.     basic.showLeds(`
  24.         . . . . .
  25.         # # . # #
  26.         # # . # #
  27.         . . . . .
  28.         . . . . .
  29.         `)
  30. })
  31. radio.onDataPacketReceived( ({ receivedNumber }) =>  {
  32.     if (receivedNumber == 3) {
  33.         iBIT.Motor(ibitMotor.Forward, 60)
  34.     } else if (receivedNumber == 1) {
  35.         iBIT.Spin(ibitSpin.Left, 50)
  36.         basic.pause(150)
  37.         iBIT.MotorStop()
  38.     } else if (receivedNumber == 7) {
  39.         iBIT.Motor(ibitMotor.Backward, 50)
  40.     } else if (receivedNumber == 2) {
  41.         iBIT.Spin(ibitSpin.Right, 50)
  42.         basic.pause(150)
  43.         iBIT.MotorStop()
  44.     } else if (receivedNumber == 8) {
  45.         iBIT.Motor(ibitMotor.Forward, 100)
  46.     } else if (receivedNumber == 5) {
  47.         iBIT.Spin(ibitSpin.Left, 70)
  48.         basic.pause(150)
  49.         iBIT.MotorStop()
  50.     } else if (receivedNumber == 6) {
  51.         iBIT.Spin(ibitSpin.Right, 70)
  52.         basic.pause(150)
  53.         iBIT.MotorStop()
  54.     } else {
  55.         iBIT.MotorStop()
  56.     }
  57. })
  58. input.onGesture(Gesture.ScreenUp, () => {
  59.     radio.sendNumber(9)
  60.     basic.showLeds(`
  61.         . . . . .
  62.         . # # # .
  63.         . # # # .
  64.         . # # # .
  65.         . . . . .
  66.         `)
  67. })
  68. input.onGesture(Gesture.TiltLeft, () => {
  69.     radio.sendNumber(5)
  70.     basic.showLeds(`
  71.         # # . . .
  72.         # # . . .
  73.         # # . . .
  74.         # # . . .
  75.         # # . . .
  76.         `)
  77. })
  78. input.onGesture(Gesture.TiltRight, () => {
  79.     radio.sendNumber(6)
  80.     basic.showLeds(`
  81.         . . . # #
  82.         . . . # #
  83.         . . . # #
  84.         . . . # #
  85.         . . . # #
  86.         `)
  87. })
  88. input.onGesture(Gesture.LogoDown, () => {
  89.     radio.sendNumber(8)
  90.     basic.showLeds(`
  91.         . . . . .
  92.         . . . . .
  93.         . . . . .
  94.         # # # # #
  95.         # # # # #
  96.         `)
  97. })
  98. input.onGesture(Gesture.Shake, () => {
  99.     radio.sendNumber(4)
  100.     basic.showLeds(`
  101.         . . . . .
  102.         . . . . .
  103.         . . . . .
  104.         . . . . .
  105.         . . . . .
  106.         `)
  107. })
  108. input.onButtonPressed(Button.B, () => {
  109.     radio.sendNumber(2)
  110.     basic.showLeds(`
  111.         . . . . .
  112.         . . . # #
  113.         . . . # #
  114.         . . . . .
  115.         . . . . .
  116.         `)
  117. })
  118. radio.setGroup(50)
  119. basic.showIcon(IconNames.Yes)
Advertisement
Add Comment
Please, Sign In to add comment