Tuesday, October 31, 2006

Coding for Random Sounds

Here is the program:

int speakerOut = 9;
int delTime = 0;
int baseTime = 0;
int ranFreq = 0; //Pulse Width (PW)
int maxTime = 10;

void setup() {
pinMode(speakerOut, OUTPUT);
}


void loop(){
ranFreq = random (850,2050);
maxTime = random (5,40);
delTime = random (100,1000);
//This for loop sets the length of the note
for (baseTime =0; baseTime < maxTime; baseTime++){
//This sets the frequence f = 1/t or PW = 1/(2*f) time is in microseconds
digitalWrite(speakerOut,HIGH);
delayMicroseconds(ranFreq);
digitalWrite(speakerOut,LOW);
delayMicroseconds(ranFreq);
}
//Pauses between notes
delay(delTime);
}

Monday, October 30, 2006

The speaker is up and running with the play_melody example!! I tried the fade examples and they sounded horrible. I am not sure why. I connected the speaker with a 1K resistor and a 0.01mF capacitor. The speaker is from a pair of old external computer speakers (5 Watts 4 Ohms). They run very well off the Arduino power. My first iteration I was shorting out my voltage regulator because of a lack of ground. The speaker made some horrifying noises. But that problem is now solved. Now I will program some of my own notes for it to play. As for the processing end I created a random noise generator. Click on the applet to generate a random sound
Play applet
View source code

Sunday, October 22, 2006

Final Project

I have gotten Processing to detect my serial ports. However I have not tested a USB connection with Arduino to Processing. Currently I am looking for speakers I should be able to find some old ones. To generate sounds I have been using the Ess library and having problems deciphering the library (I can make sounds but having problems with modulation and duration). I might switch to Sonia if I cannot generate the sounds I want.

The Processing Code (modified from the examples in Processing version 0119):

import processing.serial.*;
Serial myPort;

void setup(){
println(Serial.list());
myPort = new Serial(this, Serial.list()[0], 9600);
}

void draw(){
while (myPort.available() > 0) {
int inByte = myPort.read();
println(inByte);
}
}

Tuesday, October 17, 2006

Vehicle

So there were several problems with this project. I had a software problem with my Mac. You have to run a program that is included with Arduino to allow the computer to receive the data from the board. Once I solved that problem I had to adjust the if statement through the programing and selecting the resistance in the static resistor. Once that was solved I could not get the motor to turn on and off. This was due to two problems. One was that the power kept on falling out and I did not notice. Second was the resistor leading to the transitor. Once that was removed the motor ran. Unfortunately my cardboard car could not run on the motor due to weight. So I made a boat. It is not waterproof so I need help in creating a water-proof case for the motor. The TIP120 runs VERY hot I need a more powerful transistor. I might post a video of the boat running.



The code:
//Arduino analogRead Code Sample
int sensorPin = 1; // select the input pin for sensor
int motorPin = 13; // select the pin for the LED/Motor
int ledPin = 4; // select the pin for the LED/Motor
int val = 0; // variable to store the sensor value
byte treatedVal=0;
void setup() {
pinMode(motorPin, OUTPUT); // declare the motorPin as an OUTPUT
pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
pinMode(sensorPin,INPUT); //both digital and analog pin set to input
Serial.begin(9600); // connect to the serial port
}
void loop() {
val = analogRead(sensorPin); // read the value from the sensor
treatedVal = val/4; //converts to 8-bit numbers
Serial.println(treatedVal, DEC); // send the treated value for sensor
if (val > 700) { //checking againt a treshold 700
digitalWrite(motorPin, HIGH); // turn the motorPin on
digitalWrite(ledPin, HIGH);
}
else
{
digitalWrite(motorPin, LOW); // turn the motorPin off
digitalWrite(ledPin, LOW);
}
}
Breadboard

Tuesday, October 10, 2006

DC Motors

So a few problems with this assignment. One, I figure out the code but could not figure out what to do with it. The application of the switch case eludes me. Secondly someone took my power supply...I need to order a new one now (it has my name on it should someone find it). Thirdly, I went out bought a cheap toy but the motor was not really great. So I must order a motor or two.


On a better note I came up with an idea for a final though the full process of this idea is rather large and would take the better part of a year to finish. So I will probably make a prototype. I saw Marcin Ramocki's "Torcito Project; Deepak" at the Art Moving Projects Gallery. He had a piece that took 2-bit images of people and translated them into music. It was an alternate note system for music. Because of my special education background I am always interested in alternate means of doing something. I enjoyed alternate language communication when I taught autistic children. This led me to the idea of music as spoke language. It would be interesting to create a robot that spoke music to a program in a computer and the computer spoke back to the robot. This would involve some help with music theory (though everyone can use a little Charles Ives, Gavin Bryars, or John Cage now and then). In theory the two devices could have a full length conversation with parameters and some random note creation. A final set would allow a person to interact with the computer or the robot and allow themselves to shape and be shaped by this musical conversation.