1. LED

This is the first challenge - learn some programming and create some Morse code!

Language
C++
Est. Time
15—45min
Difficulty
Easy

Requires a PC and a Hedgehog Bot kit

From the kit, you'll need just your WeMos board and a microUSB cable. 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

    1. Download Arduino IDE from arduino.cc, install and open it.
    2. Click File→Preferences, and paste http://arduino.esp8266.com/stable/package_esp8266com_index.json into Additional Boards Manager URLs.
    3. Click Tools→Board→Boards Manager…, then click Type→Contributed followed by esp8266 by ESP8266 Community. Click Install.
    4. Download the required libraries
    5. Extract the libraries and copy the folders inside to your Arduino libraries folder (on Windows, usually Documents\Arduino\libraries).

      In Windows 8.1, your default Documents folder may be in OneDrive.

      If using macOS, or your hedgehog is not recognised, Download the CH341 driver

  2. Connect the board

    1. Connect the WeMos board to your PC using the microUSB cable.
    2. Click Tools→Board→Wemos D1 R2 & Mini.
    3. Click Tools→Port→COMx, where x is any number greater than 1.
  3. LEDs and Loops

    A LED (Light Emitting Diode) is a little light which is built into your WeMos. It’s a great thing to use to try out some code. Before you start coding, you need to know about comments, the setup and loop:

    // this is a comment, started with a //
    // it is used to explain something in your code
    
    void setup() {
      // here, between the {} we're inside the setup
      // this happens first to set up things!
    }
    
    void loop() {
      // here, between the {} we're inside the loop
      // this happens after the setup
      // this then repeats over and over again forever!
    } 
    
  4. The builtin LED is an Active LOW component meaning that setting it LOW turns it on and setting it HIGH turns it off. Active HIGH components turn on when set HIGH and turn off when set LOW.

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

    1. turn off the LED for one second
    2. turn on the LED for one second
    3. repeat over and over!
    void setup() {
      pinMode(BUILTIN_LED, OUTPUT); // set up the LED
    }
    
    void loop() {
      digitalWrite(BUILTIN_LED, HIGH); // turn off LED
      delay(1000); // wait one second
      digitalWrite(BUILTIN_LED, LOW); // turn on LED
      delay(1000); // wait one second
    } 
    
    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.
    3. You should see an LED flashing on and off once a second on the WeMos!
    4. Now try changing the size of the delays - what do you think will happen if the delays are 2000 milliseconds instead of 1000? Upload the code to see!
  5. Morse Code

    Now you know how to change the speed of flashing of your LED, let’s use that to make some Morse code! Your challenge is to spell SOS using the LED.

    Use the chart below for help. A dot is a short pulse of light, and a dash is a long pulse. Don’t forget to add an extra delay at the end of the word.

  1. Challenge Complete!

    You should now know a bit about LEDs, loops, delays and Morse code. When you're ready, continue to the next challenge.

Next

2. Bot