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.
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:
if (result.result_nbr > 0)
// We get a horn
uint8_t horn = 0;
// Turn the horn on
horn = 1;
msg.header.target = result.result_table->id;
msg.header.target_mode = IDACK;
msg.header.size = sizeof(uint8_t);
msg.header.cmd = IO_STATE;
msg.data = horn;
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.
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.
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:
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.