Arduino Uno Button Control Code
Buttons are simple switch mechanisms for controlling some aspect of a machine or a process. Buttons can be pressed or released. You can always ask the state of a button. You can connect multiple buttons to your microcontroller, but do not forget to add them to your programcode. Buttons use digital pins which are special microcontroller pins with HIGH or LOW states. This depends if the button is pressed or not.
Required hardware
- Arduino Uno
- Button
- Resistor 1kΩ
Source code to install on controller
Before you upload this code to your Arduino, please format the EEPROM...
#include <OzIDManager.h> #include <OzButtonController.h> OzIDManager* manager; OzButtonController* buttonController; const int buttonPin = 2; const int edgeTypeMode = CHANGE; void setup() { Serial.begin(115200); manager = new OzIDManager; manager->_sendACK = true; manager->_checksum = true; OzCommunication::setIDManager(manager); buttonController = new OzButtonController(buttonPin, edgeTypeMode); int x=1; manager->sendLinkSetup(); manager->PrintWelcomeLine(buttonController, x++, "MyButton"); } void loop() { OzCommunication::communicate(); buttonController->update(); }
More information