Button Command Sender
This example demonstrates a common ArmorLink pattern: local firmware logic sends Commands into the network.
The button remains normal application code. ArmorLink only transports the command.
Complete Example
#include <ArmorLink.h>
#define BUTTON_PIN 4
ArmorLinkModule module(
"Left Hand",
ArmorLinkModuleType::Hand
);
bool lastButtonState = HIGH;
void setup()
{
Serial.begin(115200);
delay(500);
pinMode(BUTTON_PIN, INPUT_PULLUP);
ArmorLinkOptions options;
options.nodeName = "Left Hand";
options.enableGateway = false;
options.enableEspNow = true;
options.enableBle = false;
options.enableSerialLogging = true;
options.defaultLogTarget = "Chest";
ArmorLink.begin(module, options);
}
void loop()
{
ArmorLink.loop();
bool currentState = digitalRead(BUTTON_PIN);
if (lastButtonState == HIGH && currentState == LOW) {
onButtonPressed();
}
lastButtonState = currentState;
}
void onButtonPressed()
{
ArmorLink.debug("Button pressed");
ArmorLink.sendCommand("Helmet", "Facemask", "toggle");
}
Matching Action on the Target
module.actions()
.add("toggleFaceplate")
.label("Toggle Faceplate")
.section("Faceplate")
.command("Facemask", "toggle")
.onExecute([] {
toggleFaceplate();
});
Sending to the Gateway
ArmorLink.sendCommand("Chest", "BTN_L1", "SINGLE_CLICK");
Use this when the Gateway acts as a central controller.
Broadcast Commands
ArmorLink.broadcastCommand("Flaps", "toggle");
Every module receives the command. Only modules with a matching Action react.
Typical Use Cases
- Hand controllers
- Hidden suit buttons
- Reed switches
- Voice recognition modules
- Gesture controllers
- Sensor-triggered actions