Vehicle

I tied six balloons to a piece of foam core. The had glued a fan through the foam core that was connected to the Arduino. The balloons where balanced and weighted so that the vehicle stayed stationary unless there was a lot of wind. The Ir sensor was supposed to read the distance that the balloons where from it. It would then send pulses to the fan to start so that the vehicle would float up a little. when the fan stopped and the vehicle floated down, when it got back to its original height, the fan would start again.


code:
int fanPin = 1;
int analogPin = 3;
int val = 0;
int threshold = 0;

void setup()
{
pinMode(fanPin, OUTPUT);
pinMode(analogPin, INPUT);
pinMode(fanPin, LOW);
delay(20);
int threshold = analogRead(analogPin);


}

void loop()
{
val = analogRead(analogPin);
if (val <= threshold) {
digitalWrite(fanPin, HIGH);
delay(5000);
digitalWrite(fanPin, LOW);
} else {
digitalWrite(fanPin, LOW);
}
}

No comments: