Drumbooth controller with Raspberry Pi, JavaFX, and Arduino

Based on multiple examples from my book “Getting started with Java on Raspberry Pi”, I created a touchscreen controller for the drum booth of my son. Combined with relays boards and an Arduino this allows to control LED strips and different lights with a touch screen interface.

There is also a web server included so we can trigger some events from anywhere in the house through a webpage so we don’t need to yell anymore from down the stairs when food is on the table ;-)

The whole setup is connected after a 220V power switch to turn off everything when the booth is not in use. The Java application automatically starts at power-up of the Pi. One of the 220V lights is connected to the open side of the relay, so there is immediate light when that 220V switch is toggled on.

Material list


Source code

This project is a combination of multiple examples of my book which are all shared in this GitHub project “JavaOnRaspberryPi”. The project itself is also shared on GitHub as “DrumBoothController”.

As it uses both a Raspberry Pi and an Arduino, you’ll find two directories in the sources.

The commands shared between both boards are strings in the structure “COMMAND_ID:SPEED:R1:G1:B1:R2:G2:B2”, where the command ID is one of the following options:

Some examples

Arduino to control the LED strips

As I’m using three parallel LED strips, I wanted to have the same effect on all three of them. So the code starts with the initialization of the strips.

Adafruit_NeoPixel strip1 = Adafruit_NeoPixel(NUMBER_OF_LEDS, PIN1, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel strip2 = Adafruit_NeoPixel(NUMBER_OF_LEDS, PIN2, NEO_GRB + NEO_KHZ800);
Adafruit_NeoPixel strip3 = Adafruit_NeoPixel(NUMBER_OF_LEDS, PIN3, NEO_GRB + NEO_KHZ800);

The communication between both boards is done with a serial link (not Mosquitto as in the book because I only want to use one controller in this case). Therefor in the loop-method the serial data is read and handled.

void loop() {  

  // Only do LED effect when loop exceeds the defined animationSpeed
  if (currentLoop >= animationSpeed) {
    // Depending on the commandId, call the correct LED effect
    if (commandId == 1) {
    } else if (commandId == 2) {
    } else if (commandId == 3) {

    currentLoop = 0;


Check the GitHub sources for each of the called methods.

Java and JavaFX for the Raspberry Pi

The Java application contains three different screens

An EventManager is shared between all UI-components and the Undertow web server handle to align the UI with the events which are triggered through the webpage. This event manager is also where the commands are executed to:

The following screenshots show the initial state when the running lights were selected on the LED strip UI. The second screenshot shows the state after selecting “red alert” on the web page.

End result

The web and touch screen UI’s side by side. As you can see (from 37"), changes via the web page are immediately visualized in the JavaFX UI.