This example shows how to use the I/O Control Panels to :
- monitor a digital input (a switch on pin 3)
- control a digital output (the on-board LED on pin 13)
Wiring diagram
Connect a switch on pin 3 with a pull-down resistance.
Sketch
Upload this program : 1_Basics \ 1_DigitalInputOutput
In this program, we start by initializing our base library HITIComm with HC_begin().
Then we place HC_communicate() inside the loop() to continuously handle communication between your Arduino and HITIPanel. This function also retrieves in the background the I/O configuration and values.
Finally, we configure the pins with pinMode(), and we switch the on-board LED ON at start using digitalWrite().
#include <HITIComm.h> const int pin_Switch = 3; const int pin_LED = LED_BUILTIN; void setup() { // initialize library HC_begin(); // set pins mode pinMode(pin_Switch, INPUT); // pin 3 -> INPUT pinMode(pin_LED, OUTPUT); // pin 13 -> OUTPUT // switch ON the on-board LED digitalWrite(pin_LED, HIGH); } void loop() { // communicate with HITIPanel HC_communicate(); }
Control Panels
1) Display the I/O Control Panel.
2) Toggle the switch connected to pin 3. You should see the input toggling in the Command Panel of pin 3.
3) The LED on pin 13 is already activated (according to the code). Deactivate it using the button in its Command Panel. On your Arduino, you should see the on-board LED switching OFF.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article