2. Bot

This is the second challenge - build your robot and get it moving!

Language
C++
Est. Time
30—60min
Difficulty
Intermediate

Requires a PC and a Hedgehog Bot kit

From the kit, you'll need everything: your WeMos board, microUSB cable, two motors and drivers, screen, 9V battery and adaptor, body and jumper cables. If you need to build a kit, or you don't recognise something, you can find a part list here.

This challenge is for Hedgehog Bot v2 only

Hedgehog Bot Kit V1 was distributed in 2015 and contains an Arduino Nano and breadboard. No further workshops are being developed for older versions of the kit, although a compatible version of this challenge is available here.

  1. Setup your computer

    If you’ve not installed the Arduino IDE and required libraries, complete Setup your computer from the first challenge. Please double check that your board works and can run the Blink code before continuing.

    At DigiMakers events, this has already been done for you.

  2. Build the body

    Follow the video below. Ask a helper if you’re stuck or a body part is hard to click in to another part.

  3. Wiring the screen

    Plug 4 wires from the WeMos into the back of the screen. The screen should still be mounted on the body. You don’t need to use the exact wire colours.

    VIN→+ GND→- D4→IN1 D3→IN2 D0→IN3 RX→IN4

  4. Wiring the left motor

    Plug 6 wires from the WeMos into the left motor driver. If you look at the bot with the screen facing you, the driver is on the left side of the body. You don’t need to use the exact wire colours.

    VIN→+ GND→- D4→IN1 D3→IN2 D0→IN3 RX→IN4

  5. Wiring the right motor

    Plug 6 wires from the WeMos into the right motor driver. If you look at the bot with the screen facing you, the driver is on the right side of the body. You don’t need to use the exact wire colours.

    VIN→+ GND→- D4→IN1 D3→IN2 D0→IN3 RX→IN4

  6. Plugging things in

    Plug the motor cables into the drivers. The white connector should click in to the white socket on the driver. Do this for both motors.

    VIN→+ GND→- D4→IN1 D3→IN2 D0→IN3 RX→IN4

  7. Code

    Now you’ve built your bot, it’s time to test the screen and motors.

    Have a look at the code below. This code will:

    1. draw a smile face on the robot screen
    2. turn the robot motors right for a second
    3. stop the motors for a second
    4. repeat over and over!
    #include "drawFace.h"
    #include "espDualStepper.h"
    
    void setup() {
        Draw.start(); // set up screen
        Motor.start(D8, D7, D6, D5, D4, D3, D0, RX); // set up motors
    }
    
    void loop() {
        Draw.smile(); // this draws a smile face on the Hedgehog's screen
        delay(1000);
        Motor.right(); // this makes the motors to turn right
        delay(1000);
        Motor.stop(); // this tells the motors to stop
        delay(1000);
    } 
    
    1. Copy the code above and paste into the Arduino IDE.
    2. Press the upload button . You’ll see the code compiling and uploading in the black box at the bottom. When it’s done you should see ‘Done Uploading’ just above the black box.

    If the screen isn’t displaying or the motors aren’t moving ask a helper to check your wiring. Wiring the motors incorrectly is also the №1 cause of espcomm_sync_failed errors. If it’s not clear why you’re getting this error, sometimes plugging in another board and uploading to that - or restarting your computer - then retrying with your hedgehog works.

  8. Dance!

    Now you’ve built your bot it’s time to make it dance!

    Use the following commands inside the loop to make the bot dance. Don’t forget delays!

    Motor.forward();
    Motor.reverse();
    Motor.left();
    Motor.right();
    Motor.stop();
    
    Draw.smile();
    Draw.frown();
    Draw.wink();
    
    delay();
    
  1. Challenge Complete!

    You should now know a bit about wiring, programming and dancing. When you're ready, continue to the next challenge.

Next

3. Wifi