Monday, October 8, 2007

Lab_05 | IR sensor

And then, I also tried to use an infrared ranger as one of analog sensors. Because I want to use this sensor for my midterm project.

Lab_05 | Connecting sansors

I connected my two analog sensors to analog pins 0 and 1 and a digital switch to digital pin 2.

Lab_05 | Two Analog Sensors

At first, I chose two analog sensors: a pot and a infrared ranger sensor.

Wednesday, October 3, 2007

Lab_04 | Connecting a flex sensor

I connected a flex sensor instead of a pot. When I bent a flex sensor, a servo changed. Actually I did this lab with Chris and David because we are in the same group. The voices in this video are from them .

Lab_04 | The servo follows the pot!

After I programmed the microcontroller, I could make the servo move.

Lab_04 | Programming the microcontroller

I copied and pasted this code from the lab page
but I didn't understand this code very well.

I think I need to study programming arduino more..


int servoPin = 2;
int minPulse = 500;
int maxPulse = 2500;
int pulse = 0;

long lastPulse = 0;
int refreshTime = 20;

int analogValue = 0;
int analogPin = 0;

void setup() {
pinMode(servoPin, OUTPUT);
pulse = minPulse;
Serial.begin(9600);
}

void loop() {
analogValue = analogRead(analogPin);
pulse = (analogValue * 19) / 10 + minPulse;


if (millis() - lastPulse >= refreshTime) {
digitalWrite(servoPin, HIGH);
delayMicroseconds(pulse);
digitalWrite(servoPin, LOW);
lastPulse = millis();
}
}

Lab_04 | Connect an anolog input and a servo

First of all, I connected power and ground on the breadboard to power and ground from the arduino. And then, I connected the pot to analog pin 0 as an analog input and connected a seromotor to digital pin 2. The blue wire in the right side is a servo.