Jump to content

Recommended Posts

Posted

i had some wadering done on www en fond

www.makecode.org

this is a site whit several mirco controlers 

controled by a kind of scratch

you can also program in javasrcipt

i made the folowing js code

[ not tested jet ]

	let move = "wait";
	sensors.remoteButtonTopLeft.onEvent(ButtonEvent.Pressed, function () {
	    move = "turn left"
	})
	sensors.remoteButtonTopRight.onEvent(ButtonEvent.Pressed, function () {
	    move = "forwart"
	})
	sensors.remoteButtonBottomLeft.onEvent(ButtonEvent.Pressed, function () {
	    move = "turn right"
	})
	sensors.remoteButtonBottomRight.onEvent(ButtonEvent.Pressed, function () {
	    move = "backwart"
	})
	motors.stopAll()
	forever(function () {
	    switch (move) {
	        case "turn left":
	            motors.largeBC.tank(-50, 50)
	            break
        case "forwart":
	            motors.largeBC.tank(50, 50)
	            break
	        case "turn right":
            motors.largeBC.tank(50, -50)
	            break
	        case "backwart":
	            motors.largeBC.tank(-50, -50)
	            break
	        default:
	            motors.stopAll()
	            break
	    }
	    control.waitMicros(100)
    move = "wait"
	
})
 
	

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...