This example shows how to use an ANALOG DATA Command Panel as a Setpoint to send analog values to your running Arduino program. A Setpoint is typically used to apply settings and setpoint values.
To illustrate this, let’s use Command Panel 0 to send a setpoint value to your Arduino (e.g. a temperature setpoint). Now we want to check if the setpoint value does not exceed a threshold value (e.g. max temperature allowed). If this is the case, we warn the user by switching the on-board LED on. We will use Command Panel 1 to display the threshold value.
Sketch
Upload this program : 1_Basics \ 9_AnalogData
We start our program by declaring pin 13 as an OUTPUT to control the on-board LED. We also set the threshold value to 1500.
#include <HITIComm.h> // Pins assignment const int pin_LED = LED_BUILTIN; // Analog Data assignment: const int ad_control = 0; const int ad_threshold = 1; // Threshold value int threshold = 1500; void setup() { // initialize library HC_begin(); // set pins mode pinMode(pin_LED, OUTPUT); }
Then, inside the loop(), we read the setpoint value (set from Command Panel 0), and we compare it with the threshold value. If it is bigger than the threshold value, the LED is turn on. Else, it is turned off.
Finally, we display the threshold value in Command Panel 1.
void loop() { // communicate with HITIPanel HC_communicate(); // get setpoint value from HITIPanel (Command Panel 0) int control = (int) HC_analogDataRead(ad_control); // if the received value is bigger than the threshold value if (control >= threshold) digitalWrite(pin_LED, HIGH); // turn ON the LED else digitalWrite(pin_LED, LOW); // turn OFF the LED // display threshold value in HITIPanel (Command Panel 1) HC_analogDataWrite(ad_threshold, threshold); }
Control Panels
1) Display the DATA Control Panels (“DATA” button).
2) Enter a control value smaller than the threshold value, for instance 1000. The on-board LED should remain turned off. Now enter a value that is bigger than the threshold value, say 3000. The LED should turn on.
3) Display the I/O Control Panel (“IO” button).
4) Check the state of the on-board LED.
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