The mecanum robot

Four mecanum wheels: it drives forward, slides sideways and spins, all at the same time. Everything for the robotics club lives here, and it all works from a phone.

Mecanum Workshop Connect over Bluetooth or USB. Drive, run the demos, set up and watch the sensors, and calibrate. Open → Mecanum Blocks The code editor: Blockly programs in tabs, subroutines, a simulator robot, nine demos. Runs on a robot over Bluetooth or USB, or fills the remote's nine slots. Best on a desktop. Code → Remote only With ir.ino on the robot: drive with the arrows, type a program of steps on the remote, save it in a slot, run it. No phone needed. The sonar stops it before a wall. With a one-page printable guide. How → Name a robot With rename.ino on the robot and the USB cable: type the name, Rename, done. The Bluetooth module gets the robot's name. Rename → Calibrate With calibration.ino on the robot: step by step, no sensors needed. Each step shows its numbers, with Undo and Reset. Calibrate → Two-stick controller Slide and turn at once. Analog sticks, or digital with six crab directions and speed presets. Drive → Lessons Ten intro to robotics sessions, each ready to run, with notes for K-5 and 6-12. Browse → Robot or Not? The big grid: real machines scored on sense, think and do. Argue with it, add your own. Decide → The sketch mecanum_holonomic v0.10.8 for the Arduino Uno. Open the .ino in the Arduino IDE and upload. Download → 2WD robot The club's first robot: its Workshop app, 15 lessons, the Maze Lab and the cheat sheet. Open →

The ten lessons

  1. Robot or Not? - what makes a machine a robot
  2. Same Job, Different Physics - laser, sonar and infrared
  3. Did It Actually Turn? - open loop vs closed loop
  4. Every Robot Is Different - measuring your own robot's numbers
  5. Sideways Is a Direction - mecanum wheels and adding arrows
  6. Too Much, Too Little, Just Right - tuning the line follower
  7. Roll Call on Two Wires - I2C buses and addresses
  8. When in Doubt, Stop - a robot that fails safely
  9. Robots Go Wrong - debugging like an engineer
  10. The 32 KB Backpack - engineering is choosing

Wiring at a glance

The L293D motor shield sits on the Uno and owns pins 3, 4, 5, 6, 7, 8, 11 and 12. Everything else plugs in here. The robot finds the optional parts by itself at start-up.

PinWhatNotes
A0 / A1HC-06 BluetoothAs the kit ships. The app and the sticks talk to it.
A2 / A3HC-SR04 sonar (echo / trig)Used only while no sensor is wired straight to A2 / A3.
A4 / A5I2C (SDA / SCL)IMU, laser and ADS1115 boards, see below.
D2IR remote receiver (S)Middle pin to 5V, "-" to GND. D2 has no header on the shield: solder to its pin.
D9 / D10Servo headersFree digital pins (no PWM: Timer1 times the IR remote).
D13Heartbeat LEDFree if you set USE_HEARTBEAT 0.

On the I2C bus (A4 / A5)

Give every board 5V into its VIN. The 3.3V boards (IMU, laser) go through a BSS138 level shifter: HV 5V, LV 3.3V, SDA and SCL on two of its channels.

AddressBoardNotes
0x68MPU-6050 (GY-521)Heading hold. Keep the robot still for a second at power-on.
0x28or BNO055ADD to GND (the cheap boards default to 0x29). PS0 and PS1 must read 0 V for I2C mode.
0x29VL53L0X laserDistance ahead, wall stop at 120 mm. Peel the film off the window.
0x48-0x4AADS1115 x3ADDR to GND / VDD / SDA. 8 line sensor channels and the light sensors. Powered from 5V.

The IR remote

arrowsHold to drive forward / back / slide left / slide right. Let go and it stops.
1 / 3Hold to spin left / right
OK, 5Stop. Any key stops a running demo.
4 / 6Slower / faster
9Circle strafe facing in (the one built-in demo; programs do the rest)
* / #Follow the line / seek the light

Fitting it all in

The Uno has 32 KB for the sketch, and the default build uses about 32.2 KB. Calibration runs live in a separate program, calibration.ino, which saves its numbers in the robot's EEPROM for this one to read. Every optional part is a USE_... line at the top of the sketch: 1 = in, 0 = out. Lesson 10 turns this into a challenge.

FlagPartFlash
USE_IMUMPU-6050 / BNO055 heading hold1.9 KB
USE_TOFVL53L0X laser1.3 KB
USE_IR_REMOTEIR remote on D20.8 KB
USE_ADS1115ADS1115 inputs0.35 KB
USE_SONARHC-SR04 on A2 / A30.3 KB
USE_ANALOG_MUX74HC4051 multiplexer (off by default)0.34 KB
USE_EXTRA_DEMOS20 more demos (off; fits with USE_IR_REMOTE 0)0.75 KB