LAB: Arduino 02
BlowME BlowBACK
Music Fan from che-wei wang on Vimeo.
Input: salvaged computer fan and 1 pot
Processing: translate analog input of fan speed and if the fan speed is above threshold set by pot, output sound frequency and LED brightness
Output: 1 slavaged speaker, 1 LED
int a0 ;
int a1 ;
int a2 ;
int a3 ;
void setup() {
for (int i=0;i<=13;i++){
pinMode(i, OUTPUT);
}
Serial.begin(9600);
}
void loop() {
// read the switch input:
a0 = analogRead(0);//0-1023
a1 = analogRead(1);//0-1023
a2 = analogRead(2);//0-1023
a3 = analogRead(3);//0-1023
int av0=average(0);
delay(10);
av0=(av0-a1/4+80);
Serial.println(a1);
Serial.println(av0);
//Serial.println(a1);
if(av0>5){
digitalWrite(3, HIGH);
delayMicroseconds(2000/av0);
digitalWrite(3, LOW);
delayMicroseconds(2000/av0);
}
analogWrite(11,abs(av0));//led
delay(10);
}
int counter=0;
int rawIn[20];
int average(int pin){
int count=20;
int averageOut;
rawIn[counter]=analogRead(pin);
counter++;
if(counter>count){
counter=0;
}
for (int i=0;i<count;i++){
averageOut=averageOut+rawIn[i];
}
averageOut=averageOut/count;
return averageOut;
}
soundBreeze
Input:mp3 player. I wanted to do a mic, but need an amp to read the changing voltage. (self-levels noise in the first second)
Processing: Translate sounds to analogWrite for LED and fan.
Output: LED brightness and fan speeds based on volume.
int a0 ;
int a1 ;
int a2 ;
int a3 ;
int level;
void setup() {
for (int i=0;i<=13;i++){
pinMode(i, OUTPUT);
}
Serial.begin(9600);
}
void loop() {
// read the switch input:
a0 = analogRead(0);//0-1023
a1 = analogRead(1);//0-1023
a2 = analogRead(2);//0-1023
a3 = analogRead(3);//0-1023
int av1=average(1);
int av2=average(2);
if(millis()<1000){
level=av2;
}
int volume=constrain((av2-level)*10,0,255);
analogWrite(3,volume);
delay(10);
analogWrite(11,volume);//led
delay(10);
Serial.println(volume);
}
int counter=0;
int rawIn[10];
int average(int pin){
int count=10;
int averageOut;
rawIn[counter]=analogRead(pin);
counter++;
if(counter>count){
counter=0;
}
for (int i=0;i<count;i++){
averageOut=averageOut+rawIn[i];
}
averageOut=averageOut/count;
return averageOut;
}
- Published:
- 09.25.07 / 10pm
- Category:
- ITP, Physical Computing, Work in Progress
- Related: [Lab: Electronics][Ornos : Prototype Shell 01][Lab: Arduino 01]










No comments
Jump to comment form | comments rss [?] | trackback uri [?]