Multilevel sensor

That is a Simple Sensor Multilevel example. It measures the value on the potentiometer and sends report to the controller if changed. In this example we set up 1 Sensor Multilevel channel. Channel has one function:
  • getter — function, which returns the previously saved potentiometer value. This function runs only once the controller asks.
You can read more about this channel and his functions here.
  • Z-Uno board
  • Breadboard
  • Hook up wires
  • Potentiometer
         // LED pin number
// 13 pin - user LED of Z-Uno board
#define LED_PIN 13
// Potentiometer pin number
#define POT_PIN 6

// channel number

// Last saved potentiometer value
byte lastValue;


// the setup routine runs once when you press reset:
void setup() {
  pinMode(LED_PIN, OUTPUT); // setup pin as output
  pinMode(POT_PIN, INPUT);  // setup potentiometer pin as input
// the loop routine runs over and over again forever:
void loop() {
  // read potentiometer value and save it inside a variable
  byte currentValue = (byte) (analogRead(A3) / 4);

  // if the value is different then the previously measured one
  // save it and send a report
  if (currentValue != lastValue) {
    // save the value
    lastValue = currentValue;
    // send report to the controller

byte getter(void) {
  byte tempVariable;
  tempVariable = (byte)((((word) lastValue) * 100) / 0xff);
  return tempVariable;
  1. Include Z-Uno into a network (if you do it the first time) or Exclude again (also by pressing the button three times), and then again Include (it will be useful if you already included the device, or just to check if it is not included in the network).
  2. Go to the Elements and here is your device — in this case (in sketch) , you connected a Sensor Multilevel channel, so you see the Sensor Generic and its current status (the percentage), which you can change by dimming the potentiometer (LED luminance value increases with the value of the potentiometer percentage).