Thursday, February 5, 2009

Our Code for Sketch1

The code is very similar to the AnalogInput provided by arduino.

int potPin = 2; // select the input pin for the potentiometer
int potPin2 = 3;
int ledPin = 13; // select the pin for the LED
int ledPin2 = 12;
int val = 0; // variable to store the value coming from the sensor
int val2 = 0;

void setup() {
pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
Serial.begin(9600);
Serial.println("Systems On");
}

void loop() {

val = analogRead(potPin); // read the value from the sensor
Serial.println(val);
val2 = analogRead(potPin2);
Serial.println(val2);

if (val > 100) {
Serial.print("Object Detected on Sensor 1");
digitalWrite(ledPin, HIGH); // turn the ledPin on
} else {
digitalWrite(ledPin, LOW); // turn the ledPin off
}
if (val2 > 100) {
Serial.println ("Object Detected on Sensor 2");
digitalWrite(ledPin2, HIGH); // turn the ledPin on
} else {
digitalWrite(ledPin2, LOW); // turn the ledPin off
}
}

All the images/videos are located on Zack's blog.
The biggest issue we had with this project was the wiring. The coding of was easy, but the wiring and attaching the ardruino was really really difficult, The wires kept on popping out and breaking the connection.

It is strange that one of the lights are dimmer than the other. And I don't know how to add more power to that slot without causing the code to malfunction.

Anyhow whats done is done.

No comments:

Post a Comment