Final Project – Pixel Bend

May 21, 2009 by dxd6596

For our final project, we were required to create something that was interactive and used serial communication with either a computer or another Arduino!

So we decided to use the servo motors to make cars that could be controlled with a throttle, utilizing a potentiometer for stop and go. All of that would work off of one Arduino, mean while we created a topiary/stop-light-like

Schematics and more coming soon… Once it is emailed to me!

Well I intended for there to be a video…but, apparently I did not record the video right!

Here is the code for the portion that I worked on… The topiary street light!

boolean isStop;

unsigned int time;

unsigned int lastTimeRed;

unsigned int lastTimeLEDOn;

int lastLEDOn;

int pinArray[] = {0, 2, 3, 4};

int timeRand = 1000;
int timeRandRed = 1000;

void setup() {
isStop = false;
time = millis();
lastTimeRed = time;
lastLEDOn = 1;

lightLED(1);

for(int a = 1; a timeRand) {
isStop = true;
lightLED(2);
}
} else {
if((time-lastTimeLEDOn) > 1000) {
if(lastLEDOn == 2) {
Serial.print(1, DEC);
// Serial.print(“ONE “);
lightLED(3);
lastTimeRed = time;
//Serial.println(“red”);
} else if(lastLEDOn == 3 && (time-lastTimeLEDOn) > timeRandRed) {
lightLED(1);
Serial.print(2, DEC);
isStop = false;
lastTimeRed = time;
randomSeed(time);
timeRand = random(5000, 10000);
timeRandRed = random(3000, 7000);
//Serial.println(“GREEN!!”);
}
}
}
}

void lightLED(int color) {
int prevLED = color-1;
if(prevLED < 1) {
prevLED = 3;
}

lastLEDOn = color;
lastTimeLEDOn = millis();

digitalWrite(pinArray[color], HIGH);
digitalWrite(pinArray[prevLED], LOW);
//Serial.print(color, DEC);
//Serial.print(" prev ");
//Serial.println(prevLED, DEC);

}

Project 3 – Move

April 28, 2009 by dxd6596

——————————————————
.: Code :.

int motorPin = 10;
int potPin = 2;

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

void loop() {
int val = analogRead(potPin);
val = map(val, 0, 1023, 0, 254);

Serial.println(val);

analogWrite(motorPin, val);
}

//put whatever in pin 10 and a pot in pin 2 and you should be able to control it with the pot, or whatever. let me know if you have questions.

Project 2 – Project Runway

April 14, 2009 by dxd6596

So for the second project I had this fantastic idea to create a DDR like game using fingers. Essentially, the user would put on a pair of gloves, that would have sensors in the finger tips and five LEDs running down each finger to the tip. The LEDs would light up, in a “chasing light” pattern and indicate what the next finger to tap would be. Well after attempting to solder the LEDs and resisters together and attaching it to a glove, it did not look very good. So in light of what we were able to accomplish, it has been decided that we would continue with the project and finish it, but some serious changes would have to be made, regarding where the LEDs will be. We were able to attach a button sensor to a row of LEDs and when pressed will reset the lights.

:: CODE ::
/*
* Blink
*
* The basic Arduino example. Turns on an LED on for one second,
* then off for one second, and so on… We use pin 13 because,
* depending on your Arduino board, it has either a built-in LED
* or a built-in resistor so that you need only an LED.
*
* http://www.arduino.cc/en/Tutorial/Blink
*/

void setup() // run once, when the sketch starts
{
Serial.begin(9600); // use the serial port to send the values back to the computer
}

int myPins[] = {1,2,3,4,5,8,9,10,11,12,13}; // LED connected to digital pin 13
//int potPin = 8; // select the input pin for the potentiometer
int val = 0; // variable to store the value coming from the sensor

void loop() // run over and over again
{
// val = digitalRead(potPin); // read the value from the sensor
// Serial.println(val); // print the value to the serial port
// if(val == 1)
// {
for(int i=0; i<10; i++)
{
pinMode(myPins[i], OUTPUT); // sets the digital pin as output
digitalWrite(myPins[i], HIGH); // sets the LED on
delay(100); // waits for a second
// val = digitalRead(potPin);
// if(val==0) {
// break;
}
// }
// // }
// if(val== 0)
// {
for(int i=0; i<10; i++)
{
pinMode(myPins[i], OUTPUT); // sets the digital pin as output
digitalWrite(myPins[i], LOW); // sets the LED off
}
// }
}

Project 1 – BLINK!

April 1, 2009 by dxd6596

For my first project I building one of the numbers of a digital clock.  I used seven diodes, one for each side.  I  then wrote a program for the Audrino that counts from zero to nine, programming the appropriate sides to light displaying the numbers in sequential order.