Introduction
The Robit Smart Car is a great starting point if you're new to electronics and programming. It can be easily programmed by using the accessible micro:bit and MakeCode editor.
In this guide, you will learn to use the Robit Smart Car with a Sonar Module. The smart car will be programmed to move and avoid obstacles.
After completing this guide, you will understand the basics on how to use the Robit Smart Car!
-
-
-
basic.forever(function () { robit.MotorRunDual( robit.Motors.M1, 50, robit.Motors.M2, 50 ) basic.pause(1000) robit.MotorRunDual( robit.Motors.M1, -50, robit.Motors.M2, -50 ) basic.pause(1000) })
-
let dist = 0 dist = 0 robit.MotorRunDual( robit.Motors.M1, 50, robit.Motors.M2, 50 ) basic.forever(function () { dist = robit.Ultrasonic(robit.Jpin.J1) if (dist < 5 && dist != 0) { robit.MotorStopAll() basic.pause(500) robit.MotorRunDual( robit.Motors.M1, -50, robit.Motors.M2, -50 ) basic.pause(500) } else { } })
-
let dist = 0 dist = 0 robit.MotorRunDual( robit.Motors.M1, 50, robit.Motors.M2, 50 ) basic.forever(function () { dist = robit.Ultrasonic(robit.Jpin.J1) if (dist < 5 && dist != 0) { robit.MotorStopAll() basic.pause(500) robit.MotorRunDual( robit.Motors.M1, -50, robit.Motors.M2, -50 ) basic.pause(500) } else if (dist < 15) { if (Math.randomRange(0, 99) < 45) { robit.MotorRun(robit.Motors.M1, -50) } else { robit.MotorRun(robit.Motors.M2, -50) basic.pause(500) } } else { robit.MotorRunDual( robit.Motors.M1, 50, robit.Motors.M2, 50 ) } })
-
-