/ 2004 / 2005 / 2006


SENSOR DRIVEN LIGHT CONTROL  

This is the controller that is used for the lighting system for TCR Radio. All work done by Andreas Muxel
Arduino
Urbandrift / COOP Partners





//////////////////// // talking cities // // 2006 /////// //////////////////// // // ******* // // globals // // ******* // // // pins // led + light #define ledPin 9 #define lightPin 11 // potis #define poti1Pin 1 #define poti2Pin 2 #define poti3Pin 3 #define poti4Pin 4 #define poti5Pin 5 // sensor #define sensorPin 0 // potis int poti1Value = 0; int poti2Value = 0; int poti3Value = 0; int poti4Value = 0; int poti5Value = 0; // sensor int sensorValue = 0; // light int lightValue = 0; int lightIdealValue = 0; int lightDif; int lightSmooth = 10; // impulse int impulseValue; int impulseSpeed = 1; // activity int activated = 0; // // ***** // // setup // // ***** // // void setup(){ // open the serial port at 9600 bps: (just for debugging) Serial.begin(9600); } // // **** // // loop // // **** // void loop(){ /////////////// // read potis // /////////////// // // poti 1 (impulse minimum) poti1Value = analogRead(poti1Pin)/4; // // poti 2 (impulse maximum) poti2Value = analogRead(poti2Pin)/4; // // poti 3 (impulse delay) poti3Value = (analogRead(poti3Pin)/4)/3; // // poti 4 (value where impulse starts after activated) poti4Value = analogRead(poti4Pin)/4; // // poti 5 (value to which sensor value is added) poti5Value = analogRead(poti5Pin)/4; // ///////////////// // read sensor // ///////////////// // sensorValue = analogRead(sensorPin)/4; // ////////////////// // calc impulse // ////////////////// // // // counter impulseValue += impulseSpeed; // limes // min if(impulseValue <= poti1Value){ impulseSpeed = 1; } // max if (impulseValue >= poti2Value){ impulseSpeed = -1; } // check if there is activity speaker track if(sensorValue == 0){ // delay delay(poti3Value); // check if activated if(activated == 1){ // set impulse to start impulseValue = poti4Value; // set speed to minus impulseSpeed = -1; // status activated (to do this just one time) activated = 0; } // use impulse to controll light lightIdealValue = impulseValue; } else{ // status activated activated = 1; // amplitude controll light lightIdealValue = (poti5Value/2) + sensorValue; // maximum limes if(lightIdealValue >= 255){ lightIdealValue = 255; } } // ////////////////// // smooth light // ////////////////// // difference lightDif = lightIdealValue-lightValue; // smooth lightValue += (lightDif/lightSmooth); // /////////////// // dim light // /////////////// // // led analogWrite(ledPin, lightValue); // light analogWrite(lightPin, (255-lightValue)); // //////////// // debugg // //////////// // // Serial.println(poti5Value); }




Copyright (c) 2006 Kunsthochschule für Medien Köln. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; A copy of the license is included in the section entitled GNU Free Documentation License".