1 of 15

micro:bit Automation Lab

Lights, Motors, Sensors

2 of 15

Micro:bit Automation Lab

Test your ideas for automation with the micro:bit programmable computer and electronic devices - lights, speakers, and motors

3 of 15

The DFRobot Motor Expansion Board

  • Exposes more programmable Pins�
  • Enables External Power Source - needed for most motors�
  • Control DC Motor�(Forward & Backward)

4 of 15

Connecting micro:bit to Motor Board

  • Insert micro:bit facing forward into the appropriate slot, the so-called Edge Connector�

As Shown ->

5 of 15

Connecting micro:bit to Motor Board

  1. Connect the Motor Board to external power�
  2. (optional) If not using tablet/Bluetooth, connect micro:bit to your laptop/PC using USB�

1

2

6 of 15

Infrared (IR) Proximity Sensor

Transmit

Detect

Surface

3V

GND

P0-2

Sensitivity

7 of 15

IR Proximity Sensor - Connecting to Board

Each I/O Pin Row has 3 Pins:��GND

Ground / - (Neg) / 0V

​

3V3

Regulated Power / + (Pos) / 3.3V

​

P

Programmable Pin�Digital Mode: On / Off or 0 / 3.3V

Analog Mode: 0 - 3.3V range

8 of 15

IR Proximity Sensor - Connecting to Board

​

Out - P0-16 (Green)

VCC -> 3v3

Gnd -> Gnd

Out -> P0-16

VCC - 3v3 (red)

Gnd (Black)

9 of 15

Programming IR Sensor

​

  1. Launch Browser and navigate to�https://makecode.microbit.org/�
  2. Click on (+) New Project

Connected to P8

10 of 15

Programming IR Sensor

​

​

Connected to P8

11 of 15

Programming IR Sensor

​

​

Connected to P8

12 of 15

Programming IR Sensor

​

Observations / Debugging

​

  • Do you see any red lights on the IR Sensor
    • There should be a power indicator always on
    • One light should turn on whenever you point the IR sensor at an obstacle

​

  • What does the micro:bit show?
    • Does the micro:bit seem to work at first but then get stuck???

13 of 15

Programming IR Sensor

​

​

Connected to P8

14 of 15

Programming IR Sensor

​

​

Connected to P8

Setting the pin (P8) to a Pull-Up pin changes its behavior and makes the digital read more dependable

15 of 15

Programming IR Sensor

​

Challenge

​

  • Use If/Else logic to make the LED strips, the micro:bit display, or the Servo behave differently when Pin = 0 and when Pin = 1

​

General Code Pattern