In this project, you'll create a whole bunch of actions, but don't worry, it's only three plus a bit of repetition:
- When the first button is pressed, turn on the LED, and increase the first "Counter" feed by 1
- When the first button is pressed, delay a few seconds (3), then turn the LED off.
- Repeat previous two actions for remaining buttons (each with their own counter feed)
- At a scheduled time each day, collect the counter feeds and use in an email template, then reset.
Hopefully that doesn't sound too complex, and it's worth noting you can do similar with any data on Adafruit IO.
Create the Counter feeds
When counting things on Adafruit IO you'll need somewhere to store that count. It's possible to use a variable as a temporary count holder, but variables only live inside the action briefly as that action executes, and are then destroyed again. Alternatively using another Feed is a more permanent storage option.
As you'll want to interact with the counter from more than one action it needs to be stored in a Feed.
Go to the Feeds page
Use the New Feed button, and then enter a memorable Name for the feed (the only restriction is length). I've used "💩 Poo Counter" as the name, which gives me a feed key of poo-counter
.
The new feed will show up in the Default group at the top of the feeds list (which I've renamed to "My Feeds").
Repeat the process to create the remaining counter feeds (one per button). For simplicity name them wee-counter
, nothing-counter
, and informed-counter
.
Initially the feeds have no data, which will cause errors to display during the first run of the email template. If you'd prefer you can go and manually add data to the counter feeds (like zero, or some other test number).
Add a new Action
Start by visiting the Actions page using the link in the navigation menu, where you'll see a list of your actions.
It shows their names, descriptions, enabled status, and an information icon button with more details.
Click the New Action button, enter a suitable name and optional description, e.g. "Button #1 pressed - increase counter", then submit.
You'll be brought to the new Action page and see a workspace in the centre with a single "root block" and toolbox.
It's a diagram based "programming" tool, similar to other low-code/no-code platforms.
There is a toolbox and a main workspace area where you compose your Action, attaching blocks to the root block to form your idea.
Triggers and Cooldowns
The root block has a Triggers:
section that defines the different events which can trigger the action. You can use multiple if you like, and the action will fire when any of the triggers match their condition (schedule or data).
The root block also has a Settings button (an icon with a grey cog in blue background), used for configuring delayed execution (which can also optionally reset existing delays to create a dead man's switch / fail-safe).
The other crucial bit of information is about cooldown periods. After a trigger matches, and then the action is executed, a cooldown period is activated (currently five seconds) during which all triggers are ignored.
Start by opening the Triggers category in the toolbox, and pick the trigger that says When FEED receives data that STARTS matching = 0
.
Drag and drop it onto the Triggers:
section of the root block, making sure to line up the puzzle piece edges (the notches and tabs) until the root block shows a yellow highlight.
Then to configure the block, use the Feed selector drop-down menu to select the first button Feed.
Next leave the comparison Operator selected on equals, and set the Value to 1
.
Great, that's the trigger done. Now onto the Actions:
section of the root block, where you'll select the "doing" blocks for your action.
Start with a Set Feed block from the Feeds category in the toolbox, drag + drop it into the Actions:
section.
Select the first buttons LED feed from the Feed selection drop-down.
Enter the value 1
into the Set Feed blocks value textbox.
If using a Dimmable LED component, instead of plain LED, then use the value 255
for max brightness.
Next you'll be setting the first button's counter feed to increase, using the Set / Get Feed blocks and a block from the Maths category of the toolbox.
Start by grabbing a Set Feed block and dropping it beneath the previous one.
Select the appropriate counter feed created earlier in the Set Feed blocks feed selector drop-down menu.
Now go to the Maths category in the toolbox, and grab the block that shows the plus/addition operator, then place that maths block into the Value section of the Set Feed block you've just placed.
Enter the value 1
into one of the two value text boxes inside the Maths block, and leave the operator as Plus (+).
Now grab a Get Feed Value block from the Feeds toolbox category, and finally drop it into the remaining value box of the maths block just placed.
Your action should look like this before continuing. Save the action, and choose enable if asked.
For the next action, to turn off the LED again, it's nearly identical to the first steps of the last one. The only difference is related to delayed execution, which you can configure using the root blocks Settings dialog.
Create a new action, called something like "#1 Button - LED off after 3seconds".
Setup the same trigger as before, When Button 1
receives a value that Starts
matching = 1
.
Use the same Set Feed block to change the #1 Button LED
feed value to 0
.
Now comes the interesting part, setting the delay for the Action.
Start by clicking the grey settings cog on the root block, and a new dialog opens, it's like a mini Blockly workspace just for configuring the delay options.
Drag the block for 1 Seconds
over to the right-hand side (the mini workspace area), to replace No Delay
.
Pick an appropriate amount of time in the drop-down menu for the seconds, like 3
.
Finally close the delay settings dialog by clicking on the same settings cog again.
You action should look like this, and can now be saved.
Repeat the previous two actions for each of the remaining buttons, using their dedicated LED + Counter feeds.
Before continuing, double check that the Actions page now shows the 8 Actions just created, enabled in the list.
On the next page you'll create the Action to send the scheduled email report, and then on the subsequent page learn about templates and the specifics for this project.
Page last edited June 18, 2025
Text editor powered by tinymce.