Approach
I decided to use the egg shell to mix the 3 LED colors and create a "party" like ambient for this project. I also used the motor to create a very simple "optical illusion" on top of the shell. (I could have drawn better if I were a better artist..) All the codes were modified based on previous and current assignment. I have set the potentiometers' settings to change the speed of blinking and also the speed of the motor.
Matertials
Arduino UNO
Solderless breadboard
LEDs x 3
220 ohm resistor x 3
1k ohm resistor
USB cable, Jameco
Potentiometer x 2
Tranducer
Batteries
Motor
Eggshell
Coding
/*
* one pot fades one motor
* modified version of AnalogInput
* by DojoDave <http://www.0j0.org>
* http://www.arduino.cc/en/Tutorial/AnalogInput
* Modified again by dave
*/
int pot1Pin = 0; // select the input pin for the potentiometer 1
int pot2Pin = 5; // select the input pin for the potentiometer 2
int pot1Val = 0; // variable to store the value coming from pot 1
int pot2Val = 0; // variable to store the value coming from pot 2
int led1Pin = 5; // select the pin for the LED 1
int led2Pin = 6; // select the pin for the LED 2
int led3Pin = 3; // select the pin for the LED 3
int motorPin = 9; // select the pin for the Motor
void setup() {
Serial.begin(9600);
pinMode(led1Pin, OUTPUT); // declare the led1Pin as an OUTPUT
pinMode(led2Pin, OUTPUT); // declare the led2Pin as an OUTPUT
pinMode(led3Pin, OUTPUT); // declare the led3Pin as an OUTPUT
}
void loop() {
pot1Val = analogRead(pot1Pin); // read the value from pot 1, between 0 - 1024, for dimming
pot2Val = analogRead(pot2Pin); // read the value from pot 2, between 0 - 1024, for blinking
if (pot1Val <=300 && pot2Val <=300) { // condition 1 to turn on led2pin
analogWrite(led1Pin, 255); // dim LED to value from pot1
delay(800); // stop the program for some time, meaning, LED is on for this time
analogWrite(led1Pin, 0); // dim LED to completely dark (zero)
delay(800);
analogWrite(led2Pin, 255); // dim LED to value from pot1
delay(1000); // stop the program for some time, meaning, LED is on for this time
analogWrite(led2Pin, 0); // dim LED to completely dark (zero)
delay(1000);
analogWrite(motorPin, 75); // analogWrite can be between 0-255
} // stop the program for some time, meaning, LED is OFF for this time}
else if (pot1Val > 301 && pot2Val <=300) { // condition 2 to turn on led1pin
analogWrite(led3Pin, 255); // dim LED to value from pot1
delay(300); // stop the program for some time, meaning, LED is on for this time
analogWrite(led3Pin, 0); // dim LED to completely dark (zero)
delay(300);
analogWrite(led2Pin, 255); // dim LED to value from pot1
delay(600); // stop the program for some time, meaning, LED is on for this time
analogWrite(led2Pin, 0); // dim LED to completely dark (zero)
delay(600);
analogWrite(motorPin, 150); // analogWrite can be between 0-255
}
else if (pot1Val > 301 && pot2Val > 301) { // condition 3 to turn on led3pin
analogWrite(led3Pin, 255); // dim LED to value from pot1
delay(100); // stop the program for some time, meaning, LED is on for this time
analogWrite(led3Pin, 0); // dim LED to completely dark (zero)
delay(100);
analogWrite(led2Pin, 255); // dim LED to value from pot1
delay(50); // stop the program for some time, meaning, LED is on for this time
analogWrite(led2Pin, 0); // dim LED to completely dark (zero)
delay(50);
analogWrite(led1Pin, 255); // dim LED to value from pot1
delay(150); // stop the program for some time, meaning, LED is on for this time
analogWrite(led1Pin, 0); // dim LED to completely dark (zero)
delay(150);
analogWrite(motorPin, 220); // analogWrite can be between 0-255
}
}
Image of set-up:
https://docs.google.com/file/d/0B4neM92x3k2dSWxvODhJdHAydkU/edit?usp=sharing
Video of set-up running:
https://docs.google.com/file/d/0B4neM92x3k2dQWRzNTRWMUlYNkk/edit?usp=sharing
- Login to post comments