Recommended Posts

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"
	
})
 
	

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.