Selected Courses on Digital Art-UOWM

15 Νοεμβρίου 2014

ARDUINO 06-light theremin

Filed under: ARDUINO,NOTES ON INTERACTIVE ART — admin @ 16:07

int sensorValue;
int sensorLow = 1023;
int sensorHigh = 0;

const int ledPin = 13;

void setup() {

  pinMode(ledPin, OUTPUT);
  digitalWrite(ledPin, HIGH);

  while (millis() < 5000) {
    sensorValue = analogRead(A0);
    if (sensorValue > sensorHigh) {
      sensorHigh = sensorValue;
    }
    if (sensorValue < sensorLow) {
      sensorLow = sensorValue;
    }
  }

  digitalWrite(ledPin, LOW);
}

void loop() {
  sensorValue = analogRead(A0);

  int pitch = map(sensorValue, sensorLow, sensorHigh, 50, 4000);
  tone(8, pitch, 20);

  delay(10);
}

[youtube https://www.youtube.com/watch?v=jJWGSFjNYMw&w=420&h=315]

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

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress

error: Content is protected !!