25
edits
Changes
no edit summary
[http://www.example.com link title]
Please see the link for the first assignment. I created an account with WIKI and not the class.
----
[[Image:Proposal.jpg]]
'''Midterm Final'''
Instead of making the above, I had to simplify. I took 2 motors from different devices and set them up in a box. I then connected 2 push buttons to both and painted disks with different combinations of color. The idea was to create a machine that mixed color with speed rather than mixing the paint. The project worked and the colors blended together to make different variations of blue and green. Unfortunately the glue holding them on the motors wore out in class, and they decided to fly off.
The project was damaged in transit on the way home. Instead of taking a picture I've drawn a graphic representation:
[[Image:midterm.jpg]]
----
After realizing that I couldn't get the code to work with a webcam, I decided to go back to the first possibility with a little more investment. I decided to construct a wall mounted LED display that played a beat based on the light within the room, and flashed different LEDs based on a random number generator. The LED's would in turn change resistances to photo-resistors which would cause a note to be played via the 2nd speaker. This project was not completed due to the complexity of the design and the lesser knowledge of it's programmer.
'''Project in Progress'''
[[Image:IMG_2868.JPG]]
[[Image:IMG_2863.JPG]]
[[Image:IMG_2872.JPG]]
'''Failed Attempt 1 Code:'''
int potPin = 2; // select the input pin for the potentiometer
char val = ' '; // variable to store the value of potPin as a note
int speakerPin = 9;
int length = 15; // the number of notes
char notes[] = "val"; // a space represents a rest
int beats[] = { 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 2, 4 };
int tempo = 300;
void loop() {
if (analogRead(potPin) = 0-150) {
(int val = "c";)
}
if (analogRead(potPin) = 241-335) {
(int val = "d";)
}
if (analogRead(potPin) = 336-454) {
(int val = "e";)
}
if (analogRead(potPin) = 455-560) {
(int val = "f";)
}
if (analogRead(potPin) = 561-699) {
(int val = "g";)
}
if (analogRead(potPin) = 700-899) {
(int val = "a";)
}
if (analogRead(potPin) = 900-1023) {
(int val = "b";)
}
if (analogRead(potPin) = 151-240) {
(int val = "C";)
}
void playTone(int tone, int duration) {
for (long i = 0; i < duration * 1000L; i += tone * 2) {
digitalWrite(speakerPin, HIGH);
delayMicroseconds(tone);
digitalWrite(speakerPin, LOW);
delayMicroseconds(tone);
}
}
void playNote(char note, int duration) {
char names[] = { 'c', 'd', 'e', 'f', 'g', 'a', 'b', 'C' };
int tones[] = { 1915, 1700, 1519, 1432, 1275, 1136, 1014, 956 };
// play the tone corresponding to the note name
for (int i = 0; i < 8; i++) {
if (names[i] == note) {
playTone(tones[i], duration);
}
}
}
void setup() {
pinMode(speakerPin, OUTPUT);
}
void loop() {
for (int i = 0; i < length; i++) {
if (notes[i] == ' ') {
delay(beats[i] * tempo); // rest
} else {
playNote(notes[i], beats[i] * tempo);
}
// pause between notes
delay(tempo / 2);
}
}
void loop() {
val = analogRead(potPin); // read the value from the sensor
digitalWrite(ledPin, HIGH); // turn the ledPin on
delay(val); // stop the program for some time
digitalWrite(ledPin, LOW); // turn the ledPin off
delay(val); // stop the program for some time
}