Selected Courses on Digital Art-UOWM

16 Νοεμβρίου 2014

ARDUINO08-DIGITAL HOURGLASS

Filed under: ARDUINO,NOTES ON INTERACTIVE ART — admin @ 12:33
const int switchPin = 8;

unsigned long previousTime = 0;

int switchState = 0;
int prevSwitchState = 0;

int led = 2;

long interval = 3000;

void setup() {
  for(int x = 2; x < 8; x++) {
    pinMode(x, OUTPUT);
  }

  pinMode(8, INPUT);
  Serial.begin(9600);
}

void loop() {
  unsigned long currentTime = millis();

  if(currentTime – previousTime > interval){
    previousTime = currentTime;
 
    digitalWrite(led, HIGH);
    led++;
 
    if(led == 7){
    }
  }

  switchState = digitalRead(switchPin);
  Serial.println(switchState);

  if(switchState != prevSwitchState){
    for(int x = 2; x < 8; x++){
      digitalWrite(x, LOW);
    }
 
    led = 2;
    previousTime = currentTime;
  }

  prevSwitchState = switchState;
}          

    

[youtube https://www.youtube.com/watch?v=hfyNJO4BjDY]

Δεν υπάρχουν Σχόλια

No comments yet.

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.

Powered by WordPress

error: Content is protected !!