Introduction: Loud and Flashy Android App for Arduino. No Android Programming Required
Update 1st Dec 2022: As well as the free pfodDesignerV3 Android app for menu design, there is now also a free pfodGUIdesigner Android app to design interactive GUI components
This Instructable shows you how to add sound and flashing menu items to your pfodApp controlled Arduino device. No Android Programming is required, the pfodDesigner generates the Arduino sketch for you.
pfodApp already supports big and bright menus to control your micro project and the free (and add free) pfodDesigner lets you design your menus interactively and then generate the necessary Arduino sketch for a variety of boards and connection types, bluetooth, WiFi and SMS. The latest version of pfodApp (V1.2.83+) also supports playing a notification sound when the menu is displayed and setting the menu to flash to attract the user's attention. The latest version of pfodDesigner (V1.2.830+) lets you add sound and flashing to your designed menus and allows you to preview the result.
This Instructable will cover how to add sound to a menu and how to make a menu flash. It also covers how the user can select which sound will be played. This Instructable will also cover the new “Ignore User Input” setting which lets you specify particular menu items as display only and ignores any user clicks on that item. For other tutorials on using the pfodDesigner to create an Android menu system with sub-menus for Arduino Compatible devices, check out the pfodDesigner main page.
Step 1: Adding Sound and Flashing to an Existing Menu
If you have already have pfodApp menu running and want to add sound or make a menu item flash, then it is as simple as add the 'extras' format to the menu's display text. Add <ex s> to play a sound. Add <ex f> to make the menu text flash. Add <ex i> to ignore user's clicks on this menu item. You can put these tags anywhere in the menu display text. You can repeat them and you can combine them. For example <ex sf> will both make the menu flash and play a sound when the menu is displayed.
If you are using pfodDesigner to design a new menu and generate the code for you, you can just select the menu item options “Set to play sound”, “Set to Flash”, “Responds to User Input” to have these extras added for you.
Step 2: How to Select Which Sound Plays When the Menu Is Displayed
Even if the pfodDevice requests the pfodApp play a sound, which sound is played and if a sound is played at all is controlled by the user's mobile. For this reason you should not rely on using just a sound to attract the user's attention. You should also consider using a different background colour and flashing text to attract their attention to this menu item. You should also consider the menu item may be scrolled out of view on the screen. So setting a different background colour and flashing the text on the menu prompt is also good practice to alert the user to check the menu.
In keeping with the pfod design philosophy, the menus are specified by simple strings and the actual interpretation of these strings is left to the pfodApp running on the user's mobile. The aim is that any mobile running pfodApp will be able to connect to any pfodDevice and display the menu to the user. For sounds, this means that the device only specifies that it would like a sound to be played, by sending <ex s> as part of the display text. It is up to the pfodApp to play a sound. Different mobiles have different notification sound bites available. It is up to the user to select which one they want played. This selection of the sound is on a per connection basis. That is a different sound can be selected for each pfodDevice the user connects to. The user can also select not to play a sound at all, either by choosing “Silent” or by just putting the mobile in silent mode.
Here is how to select the sound to be played. This example uses the free pfodDemo app. The process is the same for the free pfodDesigner app, to let you preview a menu with sound, and the process is also the same for the pfodApp to hear a sound when the pfodDevice you are connected to requests one.
- Download and install the free (and add free) pfodDemo. Open the pfodDemo.
- Click on the mobile's menu and select the Connections option
- The pfodApp will close the current connection and open the list of connections. On that screen, select the mobile's menu and choose the Add\Edit option. This will open the list of connections for editing.
- Click on the connection you want to edit. For the pfodDemo, this is Sample Screens. This opens the Edit Connection screen for that connect. In that screen, click on the mobile's menu and select “Sound setting”. You can set different sounds for each of your connections.
- Selecting the “Sound setting”, will play the currently selected sound, if any, and open the sound choice screen.
- As you make selections, that sound will play. If you don't hear the sound, adjust the volume setting on your mobile. When you have chosen the sound you want played when the pfodDevice requests a sound be played, click on OK. Your selected sound will be played. Click the Save icon to save your changes for this connection and then click “DONE” to exit the Edit Connections screen. You can now select a connection to connect to. For the pfodDemo and pfodDesigner there is only one connection available.
Now when the pfodDevice requests a sound be played to attract the user's attention. Your selected sound will be played.
Step 3: How to Make a Sound Play Repeatedly
Now that you have set the sound for the “Sample Screens” connection, you can click this connection name, or just exit and restart the pfodDemo app, and you will see the pfodDemo's main screen. From that screen select the “Menus and Lists” button. From that list choose the Oxygen Control Example.
When the O2 level gets too high or too low, the background turns red and the text starts flashing and a sound is played. If you don't hear a sound check your mobile's volume level and check you have selected a sound to be played, as described above, for the Sample Screens connection.
How to make a sound play repeatedly
As the above Oxygen demo above shows, you can have a sound play repeatedly. To do this for your own menus, set a refresh interval for the menu. The pfodApp will then re-request the menu at the refresh interval and play the sound each time the menu is re-displayed. The pfodDesigner lets you set a re-fresh interval of a menu and will generate the necessary command.
Step 4: Ignoring User Input
Often when designing a menu for your pfodDevice, you use a menu item to display information, like the current value of a sensor. For these display only menu items you don't expect the user to click on them, or if the user does, nothing happens in the pfodDevice. With the pfodApp V1.2.83+ you can specify a menu item to ignore user input by adding <ex i> to the display text. This prevents the pfodApp from sending any command for this menu item.
If the menu item is a slider, then the pfodApp will display it with the slider button missing to indicate that the user cannot change the slider. See the Oxygen Control Example above for an example of this display. The O2 reading is display only and the user cannot change its value, while the Oxygen Valve can be moved from Off to On.
If you are using the pfodDesigner, click on “Responds to User Input” to toggle the setting to “User input ignored”
The latest version of pfodApp (V1.2.83+) now lets you make flashy and loud apps to control your micro device. You can also make menu items to ignore user input, i.e. make then display only. These creating these settings are supported by the pfodDesigner (V1.2.830+), which will generate the Arduino code to send the correct pfod messages and parser the user's commands. The pfodDesigner also lets you preview your menu design complete with flashing and sound.