Projects using this component

First Program with mBot: Light Up the Onboard RGB LEDs
Upload your first code to the mBot with the Arduino IDE. The two RGB LEDs on the robot's board (mCore) light up red, green and blue together, then the right one turns yellow, the left one purple, and both go off. No wires or extra parts are needed; just connect the mBot to the computer over USB. setColor picks the color and show sends it to the LEDs.

Color Fade with mBot: A Rainbow on the RGB LEDs
The two RGB LEDs on the mBot's board fade smoothly through the colors of the rainbow: from red to green, green to blue and blue back to red. The left LED runs a little ahead of the right one on the color wheel, so the two always show different shades. No extra parts. A single number (0-255) holds the place on the wheel, and the code turns it into red, green and blue values.

First Melody with mBot: Play Notes on the Buzzer
The buzzer on the mBot's board plays the first two lines of a well-known children's song (Twinkle Twinkle Little Star), waits 2 seconds and starts over. No extra parts are needed. Every note is a frequency (Hz) and a length; the melody lives in two lists, one with the notes and one with the beat counts. The tone command plays a note and waits until it is over.

Change Colors with the mBot Button: A New Color on Every Press
Every press of the button on the mBot's board moves the two RGB LEDs to the next color: red, green, blue, yellow, purple, cyan, white and off. Holding the button does not change the color again; one press is one step. No extra parts are needed. The button is read as an analog value on pin A7: close to 0 while pressed, up at 1023 when released.

mBot Melody Picker: Press the Button, Change the Tune
Every press of the button on the mBot's board makes the buzzer play the next melody. There are three short melodies; after the third it goes back to the first. No extra parts are needed. The melodies live in one table: one melody per row, eight beats each. Pressing the button while a melody plays changes nothing, because tone holds the code until the note is over.

mBot Drive Forward and Stop: First Move with the Motors
Press the button on the mBot's board: the robot waits one second, drives straight forward for two seconds and stops. Every press repeats the move. No extra parts are needed. The two motors are plugged into M1 and M2; to go straight the left motor gets a negative speed and the right motor a positive one.

mBot First Drive: Forward, Backward, Right and Left
Press the button on the mBot's board and the robot does the four basic moves in turn: it drives forward, comes back, turns right on the spot and turns left. Each move is a function of its own. No extra parts are needed. In a turn the two wheels spin in opposite directions; the TURN_MS time sets the angle.

mBot Square Drawing Robot: Four Sides with a Loop
Press the button on the mBot's board and the robot draws a square on the floor: it drives along one side, makes a quarter turn to the right on the spot and repeats this four times. It ends where it started. No extra parts are needed. The SIDE_MS time sets the side length and the TURN_MS time sets the turning angle.

mBot Speed Levels: Slow, Medium, Fast
Press the button on the mBot's board and the robot drives forward and back at three speeds: slow first, then medium, then fast. The time is always the same; the higher the speed, the farther the robot goes. No extra parts are needed. The speeds sit in the SPEEDS table: 100, 170 and 255.

mBot Night Light: LEDs That Turn On in the Dark with the Light Sensor
The light sensor on the mBot's board measures the ambient light. When it gets dark the two RGB LEDs light up warm white; when it gets bright they go off. No extra parts are needed. The on and off limits differ (300 and 450), so the lamp does not flicker at the edge. The reading is printed to the Serial port.

