Here’s how it’s done:
Line 1: Serial.print (“!POBJ lbar_84 =
dev\\bars\\bar_hor_red_”);
The first line simply outputs a portion of the bar
graph without the actual number appended at the end:
Line 2: Serial.print (sensorValue / 102);
This line takes the sensorValue that can range from
0 to 1023, and divides it by 102 to create a “0 to 10”
integer value result. This, then, corresponds to the
number of the bar graph to send to MakerPlot:
Line 3: Serial.println (“.gif”);
The next line appends the .gif suffix to the LED bar
graph name; the Serial.println instruction also sends a
carriage return, thus terminating the MakerPlot
instructions. Note that Line 1 and Line 2 used the
Serial.print that doesn’t apply a carriage return:
Line 4: Serial.println ();
While this was a simple
example of how to send controls
to MakerPlot directly from a micro,
What this code snippet does is construct the name of
the LED bar graph image based on the potentiometer
value (or sensorValue in the sketch itself).
The last line simply sends a blank carriage return
that MakerPlot interprets as the final end of the
previous instruction. The final result is the LED bar graph
with the appropriate number of lit segments. Since we’ve
already placed the first LED bar graph in the setup, all
MakerPlot needs is the image
name we give it from these four
lines.
The Sketch in Action
First, we need to run
MakerPlot with the
My_Interface.spm Interface. When
the red rocker switch is clicked and
the sketch is run for the first time,
the two controls are placed in the
rectangular area as in Figure 4.
As the potentiometer is
adjusted, the LED bar graph
illuminates with the correct
number of bars as in Figure 8.
Conclusion
52 July 2014