Kinetische Skulptur ›paint it black‹

Kinetische Skulptur ›paint it black‹

pib-1-1-bearbeitet
dscf9529

›paint it black‹ verwendet lo-fi Elektronik und stochastische Operationen: Ein schwarzer Stift wird durch Servos, Solarzellen und Akku in einem Random Walk über eine Leuchtstoffröhre bewegt. Mit fortschreitender Zeit wird die Röhre dadurch immer stärker durch schwarze Farbe bedeckt, bis schließlich zu wenig Licht austritt, um die Solarzelle des Vehikels weiter zu speisen und seine Bewegung nicht weiter vollführen kann. Es hat sich seiner Existenzgrundlage beraubt.


// --------------------------------------------------
// paint it black
// Language: Arduino/Processing
// Author: Andreas Pirchner
// --------------------------------------------------
#include "Servo.h" 

unsigned long currentTime;
unsigned long lastTime = 0;
unsigned long servoCounter = 0;

int stepDirection;
unsigned long stepDuration;
int stepAngle;
int velocity = 190;

const int buttonPinLeft = 3;
const int buttonPinRight = 4;
const int ledPin = 7;
/*
Pushbutton buttonLeft(buttonPinLeft);
Pushbutton buttonRight(buttonPinRight);*/
Servo myservo;

void setup() {
    pinMode(10, OUTPUT);
    /*pinMode(11, OUTPUT);*/

    pinMode(8, OUTPUT);
    pinMode(9, OUTPUT);
    /*pinMode(12, OUTPUT);
    pinMode(13, OUTPUT);*/

    pinMode(2, INPUT); //ButtonLeft
    pinMode(3, INPUT); //ButtonRight

    myservo.attach(11);                            // Pin 11 for the servo

    ON();
    stepDuration = random(500, 2000);             // Duration for first Step
    stepAngle = random(0,180);
    changeAngle(stepAngle);                         // Angle for first Step

    stepDirection = random(2); 
}

void loop() {
    currentTime = millis();                       // measure time

    // Event 1: Next Step
    if (currentTime > lastTime + stepDuration){   // see if time for step has already passed 
      OFF();                                      //stop Motor
      stepAngle = random(0,180);
      changeAngle(stepAngle);                     // set new Angle
      if (currentTime-servoCounter > 500){
        lastTime = currentTime;
        stepDuration = random(500, 2000);           // set new Duration
        stepDirection = random(2);                  // set up motor for new direction
        if (stepDirection == 0){
          stepForeward();
          Serial.println ("Forward");
        }else{
          stepBackward();
          Serial.println ("Backward");
        }
      }
    }

}

void ON(){
    digitalWrite(10, HIGH);
    digitalWrite(11, HIGH);
}
void OFF(){
    //Turn off the Motor
    digitalWrite(10, LOW);
    digitalWrite(11, LOW);
}

void stepForeward(){
    // Set Motor to rotate forewards
    digitalWrite(10, HIGH);
    digitalWrite(8, HIGH);
    digitalWrite(9, LOW);
}
void stepBackward(){
    // Set Motor to rotate backwards
    digitalWrite(10, HIGH);
    digitalWrite(8, LOW);
    digitalWrite(9, HIGH);
}
void changeAngle(int angle){

    myservo.write(angle);                         //  set direction of the servo
    servoCounter = millis();                                   //  wait for servo to reach its position
}