Selected Courses on Digital Art-UOWM

17 Νοεμβρίου 2014

arduino14

Filed under: ARDUINO,NOTES ON INTERACTIVE ART — Ετικέτες: — admin @ 15:25
void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.write(analogRead(A0)/4);

  delay(1);
}

import processing.serial.*;
Serial myPort;

PImage logo;

int bgcolor = 0;

void setup() {
  colorMode(HSB, 255);

  logo = loadImage(“http://arduino.cc/logo.png”);
  size(logo.width, logo.height);

  println(“Available serial ports:”);
  println(Serial.list());

  myPort = new Serial(this, Serial.list()[5], 9600);
}

void draw() {
  if(myPort.available() > 0) {
    bgcolor = myPort.read();
    println(bgcolor);
  }
  background(bgcolor, 255, 255);
  image(logo, 0, 0);
}

Arduino13-feely Lamp

Filed under: ARDUINO,NOTES ON INTERACTIVE ART — admin @ 15:24
#include

CapacitiveSensor capSensor = CapacitiveSensor(4,2);

int threshold = 1000;
const int ledPin = 12;

void setup() {
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
}

void loop() {
  long sensorValue = capSensor.capacitiveSensor(30);
  Serial.println(sensorValue);

  if(sensorValue > threshold) {
    digitalWrite(ledPin, HIGH);
  }

  else {
    digitalWrite(ledPin, LOW);
  }
  delay(10);
}

ARDUINO12-

Filed under: ARDUINO,NOTES ON INTERACTIVE ART — admin @ 14:14
#include

Servo servo9;

const int piezo = A0;
const int switchPin = 2;
const int yellowLed = 3;
const int greenLed = 4;
const int redLed = 5;

int knockVal;
int switchVal;

const int quietKnock = 10;
const int loudKnock = 100;

boolean locked = false;
int numberOfKnocks = 0;

void setup() {
  servo9.attach(9);
  pinMode(yellowLed, OUTPUT);
  pinMode(greenLed, OUTPUT);
  pinMode(redLed, OUTPUT);
  pinMode(switchPin, INPUT);
  Serial.begin(9600);
 
  digitalWrite(greenLed, HIGH);
  servo9.write(0);
  Serial.println(“The box is unlocked!”);
}

void loop() {
  if(locked == false) {
    switchVal = digitalRead(switchPin);
   
    if(switchVal == HIGH) {
      locked = true;
      digitalWrite(greenLed, LOW);
      digitalWrite(redLed, HIGH);
      servo9.write(90);
      Serial.println(“The box is locked!”);
      delay(1000);
    }
  }
 
  if(locked == true) {
    knockVal = analogRead(piezo);
   
    if(numberOfKnocks 0) {
      if(checkForKnock(knockVal) == true) {
        numberOfKnocks++;
      }
      Serial.print(3 – numberOfKnocks);
      Serial.println(” more knocks to go”);
    }
   
    if(numberOfKnocks >= 3) {
      locked = false;
      servo9.write(0);
      delay(20);
      digitalWrite(greenLed, HIGH);
      digitalWrite(redLed, LOW);
      Serial.println(“The box is unlocked!”);
    }
  }
}

boolean checkForKnock(int value) {
 
  if(value > quietKnock && value < loudKnock) {
   
    digitalWrite(yellowLed, HIGH);
    delay(50);
    digitalWrite(yellowLed, LOW);
    Serial.print(“Valid knock of value “);
    Serial.println(value);
   
    return true;
  }
 
  else {
    Serial.print(“Bad knock value “);
    Serial.println(value);
    return false;
  }
}

ARDUINO11-Crystal Ball

Filed under: ARDUINO,NOTES ON INTERACTIVE ART — admin @ 11:15

THE CODE FOR 11

#include
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

const int switchPin = 6;
int switchState = 0;
int prevSwitchState = 0;
int reply;

void setup() {
  lcd.begin(16, 2);
  pinMode(switchPin, INPUT);
  lcd.print(“Ask the”);

  lcd.setCursor(0, 1);
  lcd.print(“Crystal Ball!”);
}

  void loop() {
    switchState = digitalRead(switchPin);
 
    if(switchState != prevSwitchState) {
      if(switchState == LOW) {
        reply = random(8);
        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print(“The Ball says: “);
        lcd.setCursor(0, 1);
     
        switch(reply) {
          case 0:
          lcd.print(“Yes”);
          break;
       
          case 1:
          lcd.print(“Most likely”);
          break;
       
          case 2:
          lcd.print(“Certainly”);
          break;
       
          case 3:
          lcd.print(“Outlook good”);
          break;
       
          case 4:
          lcd.print(“Unsure”);
          break;
       
          case 5:
          lcd.print(“Ask again”);
          break;
       
          case 6:
          lcd.print(“Doubtful”);
          break;
       
          case 7:
          lcd.print(“No”);
          break;
       
        }
      }
    }
 
    prevSwitchState = switchState;
  }

16 Νοεμβρίου 2014

Tutorial for Arduino:

Filed under: ARDUINO,NOTES ON INTERACTIVE ART — admin @ 17:13

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

[youtube https://www.youtube.com/watch?v=PeScmRwzQho?list=PL5D114A4EF03B87E0]

ARDUINO10 -Zoetrope

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

const int controlPin1 = 2;
const int controlPin2 = 3;
const int enablePin = 9;
const int directionSwitchPin = 4;
const int onOffSwitchStateSwitchPin = 5;
const int potPin = A0;

int onOffSwitchState = 0;
int previousOnOffSwitchState = 0;
int directionSwitchState = 0;
int previousDirectionSwitchState = 0;

int motorEnabled = 0;
int motorSpeed = 0;
int motorDirection = 1;

void setup() {
  pinMode(directionSwitchPin, INPUT);
  pinMode(onOffSwitchStateSwitchPin, INPUT);
  pinMode(controlPin1, OUTPUT);
  pinMode(controlPin2, OUTPUT);
  pinMode(enablePin, OUTPUT);

  digitalWrite(enablePin, LOW);
}

void loop() {
  onOffSwitchState = digitalRead(onOffSwitchStateSwitchPin);
  delay(1);
  directionSwitchState = digitalRead(directionSwitchPin);
  motorSpeed = analogRead(potPin)/4;

  if(onOffSwitchState != previousOnOffSwitchState) {
    if(onOffSwitchState == HIGH) {
      motorEnabled = !motorEnabled;
    }
  }

  if (directionSwitchState != previousDirectionSwitchState) {
    if (directionSwitchState == HIGH) {
      motorDirection = !motorDirection;
    }
  }

  if (motorDirection = 1) {
    digitalWrite(controlPin1, HIGH);
    digitalWrite(controlPin2, LOW);
  }

  else {
    digitalWrite(controlPin1, LOW);
    digitalWrite(controlPin2, HIGH);
  }

  if (motorEnabled == 1) {
    analogWrite(enablePin, motorSpeed);
  }
  else {
    analogWrite(enablePin, 0);
  }

  previousDirectionSwitchState = directionSwitchState;
  previousOnOffSwitchState = onOffSwitchState;
}

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

ARDUINO09-Motorized Pinwheel

Filed under: ARDUINO,NOTES ON INTERACTIVE ART — admin @ 13:34

const int switchPin = 2;
const int motorPin = 9;

int switchState = 0;

void setup() {
  pinMode(motorPin, OUTPUT);
  pinMode(switchPin, INPUT);
}

void loop() {
  switchState = digitalRead(switchPin);
  
  if(switchState == HIGH){
    digitalWrite(motorPin, HIGH);
  }
  else {
    digitalWrite(motorPin, LOW);
  }
}



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

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

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]

ARDUINO07-KEYBOARD INSTRUMENTS

Filed under: ARDUINO,NOTES ON INTERACTIVE ART — admin @ 11:24
int notes[] = {262, 294, 330, 349};
void setup() {
  Serial.begin(9600);
}
void loop() {
  int keyVal = analogRead(A0);
  Serial.println(keyVal);
  if (keyVal == 1023) {
    tone(8, notes[0]);
  }
  else if(keyVal >= 990 && keyVal <= 1010) {
    tone(8, notes[1]);
  }
  else if(keyVal >= 505 && keyVal <= 515) {
    tone(8, notes[2]);
  }
  else if(keyVal >= 5 && keyVal <= 10) {
    tone(8, notes[3]);
  }
  else {
    noTone(8);
  }
}

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

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]

Older Posts »

Powered by WordPress

error: Content is protected !!