# Bluetooth Remote Control for the Lego Droid Developer Kit

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/067/547/medium800/circuitpython_droiddeveloperkit-r2d2-with-feather-hires-landscape43-tightercrop.jpg?1544726863)

A short time ago in a very nearby galaxy (in 1999)...

```
Lego® added the[Droid Developer Kit](https://brickset.com/sets/9748-1/Droid-Developer-Kit "Lego Mindstorms Droid Developer Kit (9748)")to
the[Mindstorms](https://en.wikipedia.org/wiki/Lego_Mindstorms "Lego Mindstorms (Wikipedia)")robotic range. This included the
Micro Scout brick, a simplified version of the earlier
Scout brick with a single, bi-directional motor and a light
sensor. The Micro Scout functionality includes control via the
Visible Light Link (VLL) protocol.
```

This project revitalises the Droid kit with a&nbsp;[Bluetooth Low Energy (LE)](https://en.wikipedia.org/wiki/Bluetooth_Low_Energy "Bluetooth Low Energy (Wikipedia)") remote control for the Micro Scout brick. A [Feather M0 Bluefruit LE](https://www.adafruit.com/product/2995 "Adafruit Feather M0 Bluefruit LE") is used to receive commands from the Adafruit Bluefruit LE Connect app and send corresponding VLL commands to the brick using an LED. The app is available on both [Android](https://play.google.com/store/apps/details?id=com.adafruit.bluefruit.le.connect "Adafruit Bluefruit LE Connect (Android)") and [iOS](https://itunes.apple.com/us/app/adafruit-bluefruit-le-connect/id830125974 "Adafruit Bluefruit LE Connect (iOS)").

The code is implemented in [CircuitPython](https://learn.adafruit.com/welcome-to-circuitpython/what-is-circuitpython "Adafruit: Welcome to CircuitPython!").

## Parts
### Adafruit Feather M0 Bluefruit LE

[Adafruit Feather M0 Bluefruit LE](https://www.adafruit.com/product/2995)
Feather is the new development board from Adafruit, and like its namesake, it is thin, light, and lets you fly! We designed Feather to be a new standard for portable microcontroller cores.

This is the&nbsp; **Adafruit Feather M0 Bluefruit LE** &nbsp;- our take on an...

In Stock
[Buy Now](https://www.adafruit.com/product/2995)
[Related Guides to the Product](https://learn.adafruit.com/products/2995/guides)
![Angled Shot of the Adafruit Feather M0 Bluefruit LE.](https://cdn-shop.adafruit.com/640x480/2995-08.jpg)

### Lithium Ion Polymer Battery Ideal For Feathers - 3.7V 400mAh

[Lithium Ion Polymer Battery Ideal For Feathers - 3.7V 400mAh](https://www.adafruit.com/product/3898)
Lithium-ion polymer (also known as 'lipo' or 'lipoly') batteries are thin, light, and powerful. The output ranges from 4.2V when completely charged to 3.7V. This battery has a capacity of **400mAh** for a total of about 1.9 Wh. If you need a larger (or smaller!)...

Out of Stock
[Buy Now](https://www.adafruit.com/product/3898)
[Related Guides to the Product](https://learn.adafruit.com/products/3898/guides)
![Slim Lithium Ion Polymer Battery 3.7v 400mAh with JST 2-PH connector and short cable](https://cdn-shop.adafruit.com/640x480/3898-05.jpg)

### Adafruit Micro Lipo - USB LiIon/LiPoly charger

[Adafruit Micro Lipo - USB LiIon/LiPoly charger](https://www.adafruit.com/product/1304)
Oh so adorable, this is the tiniest little lipo charger, so handy you can keep it any project box! Its also easy to use. Simply plug in the gold plated contacts into any USB port and a 3.7V/4.2V lithium polymer or lithium ion rechargeable battery into the JST plug on the other end. There are...

Out of Stock
[Buy Now](https://www.adafruit.com/product/1304)
[Related Guides to the Product](https://learn.adafruit.com/products/1304/guides)
![Top view of Adafruit Micro Lipo - USB LiIon/LiPoly charger - v1 above a 2-pin JST cable.](https://cdn-shop.adafruit.com/640x480/1304-06.jpg)

### Part: White LED
quantity: 1
Bright white 5mm LED with narrow beam. Any handy, bright LED is worth testing as a substitute.
[White LED](https://www.mouser.com/ProductDetail/Optek-TT-Electronics/OVLEW1CB9?qs=sGAEpiMZZMtmwHDZQCdlqbkQSv8HD28Qn7If7iL%2fbKQ%3d)

### Part: 330 ohm resistor
quantity: 1
330 ohm resistor 1/4W 5%.
[330 ohm resistor](https://www.mouser.com/ProductDetail/Yageo/CFR-25JR-52-330R?qs=sGAEpiMZZMsPqMdJzcrNwiPCnpFTGbbhmZU2%2fcFziqU%3d)

# Bluetooth Remote Control for the Lego Droid Developer Kit

## Lego Micro Scout

The [Micro Scout](http://www.brickwiki.info/wiki/Micro_Scout "Lego Micro Scout (Brickwiki)") brick is included as part of two kits, the Lego [Droid Developer Kit (9748)](https://brickset.com/sets/9748-1/Droid-Developer-Kit "Lego Droid Developer Kit (9748)") and the [Dark Side Developer Kit (9754).](https://brickset.com/sets/9754-1/Dark-Side-Developer-Kit "Lego Dark Side Developer Kit (9754)") The only difference is the colour of the brick: white in the Droid kit, grey in the Dark Side kit.

![](https://cdn-learn.adafruit.com/assets/assets/000/067/404/medium800/feather_microscout-400px.jpg?1544567603)

This electronic brick was intended to be programmed by the Lego [Scout brick](http://www.brickwiki.info/wiki/Scout "Lego Scout (Brickwiki)") or [Spybot brick](http://www.brickwiki.info/wiki/Spybot "Lego Spybot (Brickwiki)") but anything which can generate the low speed light pulses of the Visible Light Link (VLL) protocol can be used. The [RCX brick](https://waterpigs.co.uk/articles/rcx-vll/ "Waterpigs: Teaching the RCX VLL") can also be used to program it. The Micro Scout has a **P** mode to process VLL commands - the **select** button cycles through the modes.

The Micro Scout is powered by 2 AA batteries. If you are digging one out of the attic or buying one second-hand from Jawas then it's important to check that there have been no battery leaks. A caustic leak can damage the [printed circuit board](https://en.wikipedia.org/wiki/Printed_circuit_board "printed circuit board (Wikipedia)") (PCB) particularly if the Micro Scout has not been stored face-up. The original manual contains some sage advice:

> Always remove the batteries from the battery box for long-term storage or if they have reached the end of their life. Liquid leaking from dead batteries will damage the battery box.

## Inside the Micro Scout

If you need to fix a Micro Scout brick this section may help.

There are four screws which are easily unscrewed to open up the brick. The blue screen clips into the battery compartment and is easy to unclip. The circuit board is more difficult to remove as there are two terminals which need to be desoldered.

![](https://cdn-learn.adafruit.com/assets/assets/000/067/392/medium800/feather_microscout-disassembled-all-hires.jpg?1544538224 Micro Scout disassembled, pcb unsoldered from battery terminals.)

This shows the PCB which has been cleaned to remove the alkaline deposits from a substantial battery leak at the negative terminal. The through-hole plating is damaged and partially missing leading to poor connectivity for the ground. This damage caused the Micro Scout to work intermittently.

![feather_microscout-pcb-batterydamage-hires.jpg](https://cdn-learn.adafruit.com/assets/assets/000/067/393/medium640/feather_microscout-pcb-batterydamage-hires.jpg?1544538324)

![feather_microscout-pcb-batterydamage-hires-zoom.jpg](https://cdn-learn.adafruit.com/assets/assets/000/067/394/medium640/feather_microscout-pcb-batterydamage-hires-zoom.jpg?1544538331)

There are a few options to repair this, the easiest approach for this particular case is to scrape away some lacquer and solder a small wire (not shown) from one side of the PCB to the other to ensure the negative terminal connects to the ground and ground plane on the other side of the PCB. Inelegant but effective.

# Bluetooth Remote Control for the Lego Droid Developer Kit

## Feather M0 Bluefruit LE

![](https://cdn-learn.adafruit.com/assets/assets/000/067/395/medium800/feather-with-led-hires.JPG?1544539804 Battery powered Feather M0 Bluefruit LE with a white LED attached (top view).)

The [Feather M0 Bluefruit LE](https://www.adafruit.com/product/2995 "Adafruit Feather M0 Bluefruit LE") is a compact board which in essence is a [Feather M0 Basic Proto](https://www.adafruit.com/product/2772 "Adafruit Feather M0 Basic Proto") with an on-board [Bluefruit LE SPI Friend](https://www.adafruit.com/product/2633 "Adafruit Bluefruit LE SPI Friend"). It's small and has a Lithium Polymer (LiPo) battery charger making it ideal for this project.

## Connecting an LED

The VLL protocol requires a light source to transmit the pulses to the Micro Scout. Surprisingly, the Feather's small, on-board, red LED can be used in dim ambient light. It struggles in brighter surroundings so an external LED is a better option.

![](https://cdn-learn.adafruit.com/assets/assets/000/067/432/medium800/circuitpython_feather-m0-bluefruit-le-ledplusresistord6_bb-retouchedled.png?1544638656 Feather M0 Bluefruit LE with a white LED and 330ohm resistor on D6 (top view).)

The diagram above and the picture below show a brighter, white LED with a [330 ohm resistor](https://learn.adafruit.com/circuitpython-digital-inputs-and-outputs/digital-outputs "Adafruit: CircuitPython Basics: Digital Outputs") connected between **D6** and **GND**. In this case the resistor has been [soldered](https://learn.adafruit.com/lets-put-leds-in-things/soldering "Adafruit: Soldering 101: Let's PUT LEDs in Things!") to the LED and the other lead has been extended a little with the offcut from the resistor. This could be done by twisting the wires together tightly for a quick, temporary, solderless prototype. The leads are bent back at the ends to double them up to make them the fit and grip the holes removing the need for soldering to the Feather.

Care needs to be taken to ensure the wires stay clear of the other connections on the Feather board. The [Blu Tack](https://en.wikipedia.org/wiki/Blu_Tack "Blu Tack (Wikipedia)") used here is holding the LED in place and also keeping the wires clear above the board. A multimeter can be used to confirm that similar putty/tak products are non-conductive.

![](https://cdn-learn.adafruit.com/assets/assets/000/067/396/medium800/feather-with-led-underneath-hires.JPG?1544539829 Feather M0 Bluefruit LE with a white LED and 330ohm resistor on D6 + Father Christmas making extraterrestial deliveries (bottom view).)

The white LED is showing up as blue partly due to the photograph being colour-balanced for the warm ambient light.

Warning: 

# Bluetooth Remote Control for the Lego Droid Developer Kit

## CircuitPython

![](https://cdn-learn.adafruit.com/assets/assets/000/067/421/medium800/feather_circuitpython_blinka-small.png?1544625631)

If you are new to CircuitPython, see [Welcome to CircuitPython!](https://learn.adafruit.com/welcome-to-circuitpython "Adafruit: Welcome to CircuitPython!")

Adafruit suggests using the Mu editor to edit your code and have an interactive REPL in CircuitPython.&nbsp;[You can learn about Mu and its installation in this tutorial](https://learn.adafruit.com/welcome-to-circuitpython/installing-mu-editor).

The code should also work on any CircuitPython compatible board using an on-board or separate SPI bus connected Bluefruit friend board.

## Installing CircuitPython on Feather M0 Bluefruit LE

For this project, the Feather M0 _Adalogger_ variant of the firmware _must_ be used as it defines **board.D8** which is used by the code.

The non-express Feather M0 boards did not originally ship with the UF2 bootloader. If **CIRCUITPY** drive disappears but no **FEATHERBOOT** appears when reset is double-clicked:

- then check [CircuitPython Troubleshooting](https://learn.adafruit.com/welcome-to-circuitpython/troubleshooting#cplayboot-trinketboot-featherboot-or-gemmaboot-drive-not-present-18-4 "Adafruit: Welcome to CircuitPython! Troubleshooting") first and if **FEATHERBOOT** is still missing then use [CircuitPython Non-UF2 Installation](https://learn.adafruit.com/welcome-to-circuitpython/non-uf2-installation "Adafruit: Welcome to CircuitPython! Non-UF2 Installation"),
- else use [Installing CircuitPython (UF2)](https://learn.adafruit.com/welcome-to-circuitpython/installing-circuitpython "Adafruit: Welcome to CircuitPython! Installing CircuitPython").

Ensure you have the **CIRCUITPY** drive appear when you plug your Feather into your computer via a known good USB cable. The version of CircuitPython you are running can be seen either in the Mu editor Serial/REPL or by the text in the file **boot\_out.txt** on the **CIRCUITPY** drive.

## Libraries

Download the latest set of libraries for CircuitPython to match the version of CircuitPython you are running. There is one library package for CircuitPython 3.x, 4.x, and so on. Click the box below and download the library bundle to your computer.

[Click to go to the latest Adafruit CircuitPython Library Bundle Release Page](https://github.com/adafruit/Adafruit_CircuitPython_Bundle/releases/latest)
Two libraries are needed for the code. Open the library Zip file and copy the following files onto the Feather **CIRCUITPY** &nbsp;drive in a directory called **/lib**

- **adafruit\_bus\_device**
- **adafruit\_bluefruitspi**

See the [CircuitPython Libraries](https://learn.adafruit.com/adafruit-hallowing/circuitpython-libraries "Adafruit: Hallowing: CircuitPython Libraries") guide for additional details on how to add libraries.

## Code

Adafruit recommends copying this file to the board using the target filename **code.py** on the Feather M0 Bluefruit LE.

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Bluetooth_Remote_for_Lego_Droid_Kit/code.py

This code makes use of [Jorge Pereira's VLL python code](https://github.com/JorgePe/mindstorms-vll "GitHub: JorgePe/mindstorms-vll").

This code has been tested on a Feather M0 Bluefruit LE running CircuitPython 3.1.1.

# Bluetooth Remote Control for the Lego Droid Developer Kit

## Remote Control

## Install the App

Download the Adafruit Bluefruit LE Connect app on either an [Android](https://play.google.com/store/apps/details?id=com.adafruit.bluefruit.le.connect "Adafruit Bluefruit LE Connect (Android)") or [iOS](https://itunes.apple.com/us/app/adafruit-bluefruit-le-connect/id830125974 "Adafruit Bluefruit LE Connect (iOS)") device with Bluetooth.

## Attach the Feather Board to the Droid

There are lots of different ways to attach the Feather board:

- extra Lego to hold the board in place,
- a custom-made 3d printed holder,
- two pieces of black insulating tape.

The last option was used with the battery hanging off precariously.

![](https://cdn-learn.adafruit.com/assets/assets/000/067/397/medium800/feather-attached-to-microscout-medres.JPG?1544551366 Feather M0 Bluefruit LE board temporarily attached to Micro Scout brick with insulating tape. LED alignment with the photodiode (light sensor) could be better!)

The LED must be aligned with the [photodiode](https://en.wikipedia.org/wiki/Photodiode "photodiode (Wikipedia)") light sensor. In bright conditions it may help to cover/shroud this area to stop ambient light interfering with the light pulse communication.

Warning: 

## Droid Remote Control

Ensure the Micro Scout brick is in **P** mode, tap connect in the tablet for the **BlueMicroScout** and start sending commands to the droid:

 **Button -\>&nbsp;**** Action**

- Up -\> Reverse
- Down -\> Forward
- 1 -\>&nbsp;Beep

It's possible the droid in this example is built incorrectly with the direction mechanically reversed. The intention of the code is for the direction to be the other way around!

![](https://cdn-learn.adafruit.com/assets/assets/000/067/399/medium800thumb/feather_droiddeveloperkit-r2d2-bluetooth-rc-demo1-480x360-bordered.jpg?1544556704 Droid remote-controlled by Adafruit Bluefruit LE Connect app over Bluetooth.)

If the droid starts misbehaving by following a different command, this is likely to be due to a reported&nbsp;[bug](https://github.com/adafruit/Adafruit_CircuitPython_BluefruitSPI/issues/9 "GitHub: adafruit/Adafruit\_CircuitPython\_BluefruitSPI: read\_packet needs to check for leftover data in self.\_buffer (#9)").&nbsp;

# Bluetooth Remote Control for the Lego Droid Developer Kit

## Going Further

## Ideas for Areas to Explore

- Implement "bump and turn" functionality with an accelerometer or an alternative board which contains an accelerometer like the (larger) [Circuit Playground Express](https://www.adafruit.com/product/3333 "Adafruit: Circuit Playground Express").
- Add additional [servos](https://learn.adafruit.com/using-servos-with-circuitpython/circuitpython "Adafruit: Using Servos With CircuitPython and Arduino: CircuitPython") to rotate the head and control the foot direction.
- Compare with the more advanced bluetooth remote control addition to the Hasbro R2-D2 by Chris Lydgate: [The Resurrection of R2-D2](https://www.youtube.com/watch?v=k7Ow374l4ro "YouTube: Chris Lydgate: The Resurrection of R2-D2") (YouTube).

## Related Projects

- [MUNNY Glowing Friend with Bluetooth Control!](https://learn.adafruit.com/munny-lamp "Adafruit: MUNNY Glowing Friend with Bluetooth Control!")

## Further Reading

- [Introducing Adafruit Feather](https://learn.adafruit.com/adafruit-feather "Adafruit:Introducing Adafruit Feather")
- [All the Internet of Things - Epsiode One: Bluetooth & BTLE](https://learn.adafruit.com/alltheiot-transports/bluetooth-btle "Adafruit: All the Internet of Things - Epsiode One: Bluetooth & BTLE")
- [Adafruit Bluetooth Low Energy (BLE) FAQ](https://learn.adafruit.com/adafruit-feather-m0-bluefruit-le/faq "Adafruit: BLE FAQ").


## Featured Products

### Adafruit Feather M0 Bluefruit LE

[Adafruit Feather M0 Bluefruit LE](https://www.adafruit.com/product/2995)
Feather is the new development board from Adafruit, and like its namesake, it is thin, light, and lets you fly! We designed Feather to be a new standard for portable microcontroller cores.

This is the&nbsp; **Adafruit Feather M0 Bluefruit LE** &nbsp;- our take on an...

In Stock
[Buy Now](https://www.adafruit.com/product/2995)
[Related Guides to the Product](https://learn.adafruit.com/products/2995/guides)
### Lithium Ion Polymer Battery Ideal For Feathers - 3.7V 400mAh

[Lithium Ion Polymer Battery Ideal For Feathers - 3.7V 400mAh](https://www.adafruit.com/product/3898)
Lithium-ion polymer (also known as 'lipo' or 'lipoly') batteries are thin, light, and powerful. The output ranges from 4.2V when completely charged to 3.7V. This battery has a capacity of **400mAh** for a total of about 1.9 Wh. If you need a larger (or smaller!)...

Out of Stock
[Buy Now](https://www.adafruit.com/product/3898)
[Related Guides to the Product](https://learn.adafruit.com/products/3898/guides)
### Adafruit Micro Lipo - USB LiIon/LiPoly charger

[Adafruit Micro Lipo - USB LiIon/LiPoly charger](https://www.adafruit.com/product/1304)
Oh so adorable, this is the tiniest little lipo charger, so handy you can keep it any project box! Its also easy to use. Simply plug in the gold plated contacts into any USB port and a 3.7V/4.2V lithium polymer or lithium ion rechargeable battery into the JST plug on the other end. There are...

Out of Stock
[Buy Now](https://www.adafruit.com/product/1304)
[Related Guides to the Product](https://learn.adafruit.com/products/1304/guides)

## Related Guides

- [Adafruit Feather M0 Bluefruit LE](https://learn.adafruit.com/adafruit-feather-m0-bluefruit-le.md)
- [Sparkle Skirt Playground](https://learn.adafruit.com/sparkle-skirt-playground.md)
- [Make a Snow Globe with Circuit Playground Express & MakeCode](https://learn.adafruit.com/make-a-snowglobe-with-circuit-playground-makecode.md)
- [LED NeoPixel Corset with Circuit Playground Express and MakeCode](https://learn.adafruit.com/led-corset-with-circuit-playground-and-makecode.md)
- [NeoPixel Fairy Crown](https://learn.adafruit.com/neopixel-fairy-crown.md)
- [Snow Globe with Circuit Playground Bluefruit](https://learn.adafruit.com/snow-globe-bluefruit-cpb.md)
- [CircuitPython Hardware: PCA9685 PWM & Servo Driver](https://learn.adafruit.com/micropython-hardware-pca9685-pwm-and-servo-driver.md)
- [Cosplay Floating LED Fireball with Motion Sensing](https://learn.adafruit.com/cosplay-fireball-prop-with-motion-sensing.md)
- [NeoPixel Basketball Hoop](https://learn.adafruit.com/neopixel-mini-basketball-hoop.md)
- [Sword & Wand Prop Effects with Circuit Playground](https://learn.adafruit.com/sword-and-wand-prop-effects-with-circuit-playground.md)
- [Charger Charm - 3D Printed holder for Micro LiPo USB Charger](https://learn.adafruit.com/usb-charger-charm-3d-printed-holder-for-micr-lipo-usb-charger.md)
- [Light-Up Angler Fish Embroidery](https://learn.adafruit.com/light-up-angler-fish-embroidery.md)
- [Easy Sparkle Pocket T-Shirt](https://learn.adafruit.com/easy-sparkle-pocket-t-shirt.md)
- [Trinket / Gemma Space Invader Pendant](https://learn.adafruit.com/trinket-slash-gemma-space-invader-pendant.md)
- [MicroLipo v2 Case](https://learn.adafruit.com/microlipo-case.md)
- [Haptic Headband](https://learn.adafruit.com/haptic-headband.md)
