"lua-stick" is a development-tool-free embedded hardware platform.
All you need is a text editor to connect virtually anything to your PC.

Similar projects worth following
The goal of this project is to make embedded hardware programming accessible to everybody everywhere, especially when no development tools can be installed easily.

lua-stick is based and centred around a STM32F401 uC. Plugged into a computer it enumerates as a mass storage device (aka USB flash drive), a keyboard, and a serial port simultaneously. On the drive there is a file, a lua script, that contains the program to be executed. Edit it using to tool of your choice, press the button, and voila, the program gets compiled and runs.


What's more annoying than being away from home and trying to program an embedded device using a foreign machine, let's say to interface an LED? - No or different dev tools, missing cables or programmers, no name the least. You may ask yourself: why is all this stuff actually needed to make a simple LED blink? Wouldn't it be great to just be able to enter these 5 lines of code without having to worry about all this frameworking?

It turns out that it is actually conceptionally quite simple to solve this problem: just run all the tools on the embedded device itself and let it communicate with the PC by make it looking like standard peripheral(s). Let USB be your friend and make your device look like a flash-stick that contains the code it should execute. Let it also look like a keyboard to let it input something and let it look like a serial port to enable bidirectional communication.

Now, one may take this one step further by asking what is the minimum device that would fulfil these needs. It can all be done essentially using a single uC, which is demonstrated by lua-stick.


  • Hardware
    lua-stick is implemented using an STM32F401 uC. Its internal flash serves to store system code as well as a 48kB FAT12 partition for user code and data. As a user-interface it contains an RGB rotary switch. 
  • Software
    lua-stick uses its USB port to enumerate itself as MSC, HID and CDC simultaneously. It contains a lua compiler and a set of libraries to communicate with the PC and the periphery.


lua-stick is a working proof-of-principle piece of hard- and software. A future version shall have a bit more electrical I/Os and a form-factor (giving up the rather large rotary switch) more compatible with a real key chain.

Use cases

The current lua-stick is already pretty universal; here are a few simple examples:

  • external PC volume control switch (using HID interface)
  • temperature logger (using CDC interface)
  • random keyboard, e.g. Alt-F4; Ctrl-Alt-Del; etc. (using HID interface)
  • LED notifier (using CDC interface)
  • Any kind of timer (no PC interface)
  • etc.

Next future lua-stick will add communication to external devices:

  • universal interface to between PC and serial line controlled electronics (using CDC interface)

Despite all the tasks above, it is a perfect vehicle to teach programming!

Openess & Connectivity

Hard- and software were developed using open tools and will become open source/hardware:

  • PCB and schematics are done in kicad.
  • All software is based on GCC, ST-supplied libraries (peripheral and USB), and lua. A lot of customisation was needed to make it working smoothly together and I am in the progress to clean up the code and sort out the different copyrights and licenses. After, all will be published on github under an appropriate open-source/-hardware license.

Connectivity is essential for this device in two ways:

  • Programming is done via USB mass-storage interface.
  • When running the software most applications will probably like to send/receive data to/from a PC. Eventually it will be the programmable babel-fish between PC and the device of your liking.

  • 1 × STM32F401 Cortex-M4 uC, SMD LQFP64
  • 1 × USB plug, type A thor
  • 1 × Voltage regulator 3V3 SOT23-5
  • 2 × capacitor, 1uF SMD, 0603
  • 1 × capacitor, 4.7uF SMD, 0603

View all 11 components

  • "Casing"

    magnustron11/02/2014 at 21:36 0 comments

    Now, I have four working parts in protected in heat shrinking tube.

  • Colour-key -- yet another use case

    magnustron08/26/2014 at 18:58 0 comments

    This might be quite useful. A key that can be programmed to change colours when turning and enter a colour-dependent phrase when pressed:

    while true do
      if     i==1 then led.rgb(1.0,0.0,0.0) if pressed then hid.hit("red") end
      elseif i==2 then led.rgb(0.0,1.0,0.0) if pressed then hid.hit("green") end
      elseif i==3 then led.rgb(0.0,0.0,1.0) if pressed then hid.hit("blue") end
      elseif i==4 then led.rgb(1.0,1.0,0.0) if pressed then hid.hit("yellow") end
      elseif i==5 then led.rgb(0.0,1.0,1.0) if pressed then hid.hit("cyan") end
      elseif i==6 then led.rgb(1.0,0.0,1.0) if pressed then hid.hit("purple") end
      elseif i==7 then led.rgb(1.0,0.5,0.5) if pressed then hid.hit("pink") end
      elseif i==8 then led.rgb(1.0,1.0,1.0) if pressed then hid.hit("white") end
      if pressed then
        while sw.get() do end 

    ... of course instead of writing the colour name, one could start applications, enter passwords (not really save though...), etc.

  • Use cases

    magnustron08/20/2014 at 23:20 0 comments

    I was told, correctly, to come up with some use cases... find them on the project details!

View all 3 project logs

  • 1
    Step 1

    Produce PCB

    Did mine with and got 10. Her shown with the USB connectors:

  • 2
    Step 2

    Assemble PCB

    Get the components and solder them (the uC might be a bit tricky at home). Not all components are needed to make it work.

  • 3
    Step 3

    Upload firmware

    When first connecting the device you should connect BOOT0 to 3V3. This makes it entering the DFU bootloader mode, allowing you to upload the firmware image. This is the only time that you actually need a tool on the PC side (besides an editor).

View all 5 instructions

Enjoy this project?



PointyOintment wrote 08/20/2014 at 00:30 point
It's more than just a programmable rotary encoder stick, right?

  Are you sure? yes | no

magnustron wrote 08/20/2014 at 05:38 point
Yes and no. It is more the idea of an embedded platform that works driver- and SDK-less what makes up the project. The current prototype has indeed just the rotary switch as I/O (and the embedded temperature sensor), and is more a proof-of-principle, but the next iteration will surely provide some GPIO/ADC. This will make the device a universal interface. - Will work on the project details tonight, giving a few use cases!

  Are you sure? yes | no

PointyOintment wrote 08/21/2014 at 21:00 point
Ah, OK. So it's similar to Screvle (also on here), then?

  Are you sure? yes | no

magnustron wrote 08/25/2014 at 09:12 point
Yes, kind of. The main (perhaps distinctive, if you like) features of lua-stick is its minimalistic and USB-centred approach. But nice to see similar projects!

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates