Skip to main content

Make our alarm evolve using a truck horn and more

For now, our alarm does not make any noise, which is sad for an alarm. Let us make some noise.

To do that, we will add another board to the setup with a relay switch. In this power switch, we put a 12V truck horn producing 150db.

luos_img

To control it, we will simply have to manage it on the apps and use the standard power_switch driver.

Add the truck horn on alarm_controller app

We simply want the horn to turn on at the same time the red LED is blinking. So we add a small message after the LED's one in the app's loop:

RTFilter_Alias(RTFilter_Reset(&result), "horn");
if (result.result_nbr > 0)
{
// We get a horn
uint8_t horn = 0;
if (!blink)
{
// Turn the horn on
horn = 1;
}
msg_t msg;
msg.header.target = result.result_table[0]->id;
msg.header.target_mode = IDACK;
msg.header.size = sizeof(uint8_t);
msg.header.cmd = IO_STATE;
msg.data[0] = horn;
Luos_SendMsg(app, &msg);
}

As you can see, we call the power_switch driver “horn”. When you use alias to get ID of a service, always make sure to rename it.

info

The simplest way to rename a service is to use a gate and Pyluos.

Add the truck horn on start_controller app

In this app, we add a small "BIP" when locking or unlocking the bike. In order to add it, we have to add more code than in the previous app to manage time properly. You consult the final code here.

We took advantage of this code modification to add some fancy animation on the LED, allowing it to be used as bicycle headlight.

Improvement clue

To make it usable in real life, we should probably select something less noisy than a truck horn which can be really painful for the ears. We also should add a real locking system which would be able to lock the bike wheel using a motor and a mechanism, like this one made by our friends from Pony:

luos_img

We can also add connectivity to set the bike up using a mobile app or something similar. This part is interesting, so let us talk about that on the next chapter.

A feedback? Let's discuss on Discord | Github

The author: Nicolas Rabault

CEO at Luos
Nicolas Rabault

Former roboticist, research engineer in real-time embedded systems and founder of Pollen Robotics, Nicolas Rabault is CEO of Luos. Nicolas dedicated his life to develop tools making embedded subsets work together and simplifying reusability.

Related content