Forum >Replies by david.lincourt
userhead david.lincourt
Replies (2)
  • You Reply: Hello Nana - A little over a second... less than 1.5 seconds.
  • You Reply: Hello Nana - thanks for your help. Here is the Javascript code. I am using Microsoft MakeCode:

    On the Robot:
    radio.onReceivedString(function (receivedString) {
    if (receivedString == "Open") {
    basic.showIcon(IconNames.SmallHeart)
    DFRobotMaqueenPluss.servoRun(Servos.S2, -150)
    }
    if (receivedString == "Close") {
    basic.showIcon(IconNames.Heart)
    DFRobotMaqueenPluss.servoRun(Servos.S2, 150)
    }
    if (receivedString == "Stop") {
    basic.showIcon(IconNames.SmallHeart)
    DFRobotMaqueenPluss.mototStop(Motors.ALL)
    }
    if (receivedString == "Left") {
    basic.showArrow(ArrowNames.West)
    DFRobotMaqueenPluss.mototRun(Motors.M2, Dir.CW, 40)
    DFRobotMaqueenPluss.mototRun(Motors.M1, Dir.CCW, 40)
    }
    if (receivedString == "Right") {
    basic.showArrow(ArrowNames.East)
    DFRobotMaqueenPluss.mototRun(Motors.M2, Dir.CCW, 40)
    DFRobotMaqueenPluss.mototRun(Motors.M1, Dir.CW, 40)
    }
    if (receivedString == "Up") {
    basic.showArrow(ArrowNames.North)
    DFRobotMaqueenPluss.mototRun(Motors.M2, Dir.CW, 40)
    DFRobotMaqueenPluss.mototRun(Motors.M1, Dir.CW, 40)
    }
    if (receivedString == "Down") {
    basic.showArrow(ArrowNames.South)
    DFRobotMaqueenPluss.mototRun(Motors.M2, Dir.CCW, 40)
    DFRobotMaqueenPluss.mototRun(Motors.M1, Dir.CCW, 40)
    }
    })
    basic.showIcon(IconNames.SmallHeart)
    radio.setGroup(1)
    DFRobotMaqueenPluss.servoRun(Servos.S2, -150)
    DFRobotMaqueenPluss.mototStop(Motors.ALL)
    basic.forever(function () {

    })

    On the Gamepad

    gamePad.onEvent(GamerBitPin.P15, GamerBitEvent.Up, function () {
    basic.showIcon(IconNames.SmallHeart)
    radio.sendString("Stop")
    })
    gamePad.onEvent(GamerBitPin.P14, GamerBitEvent.Up, function () {
    basic.showIcon(IconNames.SmallHeart)
    radio.sendString("Stop")
    })
    gamePad.onEvent(GamerBitPin.P14, GamerBitEvent.Down, function () {
    basic.showArrow(ArrowNames.West)
    radio.sendString("Left")
    })
    gamePad.onEvent(GamerBitPin.P15, GamerBitEvent.Down, function () {
    basic.showArrow(ArrowNames.East)
    radio.sendString("Right")
    })
    gamePad.onEvent(GamerBitPin.P13, GamerBitEvent.Down, function () {
    basic.showArrow(ArrowNames.South)
    radio.sendString("Down")
    })
    gamePad.onEvent(GamerBitPin.P8, GamerBitEvent.Up, function () {
    basic.showIcon(IconNames.SmallHeart)
    radio.sendString("Stop")
    })
    gamePad.onEvent(GamerBitPin.P1, GamerBitEvent.Up, function () {
    basic.showIcon(IconNames.SmallHeart)
    radio.sendString("Open")
    })
    gamePad.onEvent(GamerBitPin.P8, GamerBitEvent.Down, function () {
    basic.showArrow(ArrowNames.North)
    radio.sendString("Up")
    })
    gamePad.onEvent(GamerBitPin.P1, GamerBitEvent.Down, function () {
    basic.showIcon(IconNames.Heart)
    radio.sendString("Close")
    })
    gamePad.onEvent(GamerBitPin.P13, GamerBitEvent.Up, function () {
    basic.showIcon(IconNames.SmallHeart)
    radio.sendString("Stop")
    })
    basic.showIcon(IconNames.SmallHeart)
    radio.setGroup(1)
    radio.sendString("Open")
    basic.forever(function () {

    })