Examples - Sensorboard - Poti

Potis

This Example shows the use of Potis.





/**************************************************************************************************
*
*  Simple Poti
*
*   Version:      1.0.0 - September 2008
*   Author:       Etienne Ribeiro    / tutorial assistant caad      /  eribeiro[at]ethz.ch
*   Supervisor:   Christoph Wartmann / chair for caad - ETH Zürich  /  wartmann[at].arch.ethz.ch
*
*   Desc:         Shows the use of a Poti Sensor on analog pin.
*
***************************************************************************************************/





// Const

static int pinAnalogIn = 1;
static int pinInMaxValue = 1000;
static int pinOutCount = 5;
static int pinOut[] = {24, 25, 26, 27, 28};
static boolean enableSerial = false;




// Setup

void setup() {

        // LED (2 * blinken)
        pinMode(48, OUTPUT);
        digitalWrite(48, HIGH);
        delay(200);
        digitalWrite(48, LOW);
        delay(200);
        digitalWrite(48, HIGH);


        // Serial (Print to serial if enableSerial = true)
        if (enableSerial == true) Serial.begin(9600);


        // Pin Mode
        for (int iPin = 0;iPin < pinOutCount;iPin++) {

                pinMode (pinOut[iPin], OUTPUT);

        }

}




// Loop

void loop() {

        // Read:
        int val = analogRead(pinAnalogIn);


        // LED on/off:
        for (int iPin = 0;iPin < pinOutCount;iPin++) {
                if (pinInMaxValue / pinOutCount * (iPin + 1) > val)
                digitalWrite(pinOut[iPin], HIGH);
                else
                digitalWrite(pinOut[iPin], LOW);
        }


        // Debug
        if (enableSerial == true) {
                Serial.print(val, DEC);
                Serial.println("");
        }


        // Wait
        delay(50);

}


This website has been archived and is no longer maintained.