Monday, January 26, 2009

Connecting the [im]duino to an IR kit



Here are clearer pictures of my Arduino, (I call it A.L.I.C.E.) and an IR proximity sensor kit from e-gizmo [more info here] 300 Php per unit.

Note for fellow novices, the IR kit shown above already outputs digital signal, also it is made and sold in the Philippines, so if you need to order one from outside Philippines, ask them (site link above).
Ill probably post a how to make an IR sensor next time

If in case you have the same kit, take note that the kit outputs a "low" when an object is in its detection range (usually 25cm), testing it with an arduino platform is a walk in the park.

Here's what you do:
1. Connect your Arduino to your PC (USB/Serial/etc.)
2. Run the Arduino software
3. Click File>Sketchbook>Example>Digital>Button
4. This opens the Button sketch for the program that allows the Arduino to interact with button.
5. Replace parts of the code inside the void loop() function with what you see here, leave the rest as is.

void loop(){
val = digitalRead(inputPin); // read input value
if (val == LOW) { // check if the input is LOW
digitalWrite(ledPin, HIGH); // turn LED ON
} else {
digitalWrite(ledPin, LOW); // turn LED OFF
}
}

6. The kit shown uses 5V, connect the wires with respect to proper polarity, in this case pink to +5V, and gray to ground, and most important is the output (White wire). Connect the IR kit's output wire to pin 2, remember this is where the switch was connected to if you performed the beginner experiments. Then connect a LED (any color) positive lead into Pin 13, negative lead to ground, this will serve as your output to check if the setup (hardware connections and program) is working.

7. The changes made in the program basically changes how the Arduino behaves to input. A "low" input will cause the LED connected to Pin 13 to light up instead(remember, the IR kit outputs a "low" when an object is detected). So when the IR sensor kit is connected, whenever an object gets in the detection range, the LED in pin 13 will turn on.


And there you have it, connecting an IR kit to an Arduino. If you have a different type of IR sensor kit , youll have to identify what its output is (when an object is detected), if your kit outputs a "high" then youll have to change the condition inside the if statement to HIGH.

If your IR sensor has an analog output, you will have to set up a circuit for it, or learn how to program your arduino to accept analog sensor input. Im not yet at that level however... However Ill probably make a post on how to make one's own digital output IR sensor. Till then, Goodnight

Sunday, January 25, 2009

The First post

First post for the first timer blogger who also happens to be a first timer in the Arduino world... well not quite.

Ive been interested in Arduino since the first time I encountered it somewhere in the world wide web, described as an electronics prototyping platform, it is programmable using C language using the Arduino software
. Basically its free, its open source so practically anyone with the know how could build a board by hand. And then to program it all you need is logic and knowledge in programming C language.

Well yes its open source, but I was so lazy I preferred to buy an assembled one. Normally you could buy one for about 30 dollars in US (1300+ in Philippine pesos not including wuzzat? postage and handling thingy) Assembling it would be a lot of fun, but that probably comes later on when my Hyperspeed school gives us a lengthy vacation.

Kidding aside, I bought mine from a different source and unlike the mainstream ones out there from NG, Diecmila, Duemilanove, Bluetooth (gosh look at those variations), my Arduino is made in the Pilippines, yes it is.

Named [im]duino, this arduino variant is from [im] Imaginatech inc [site here]
Priced at 800 Philippine Pesos, its actually very affordable to the "
common Juan" I got mine just last week wednesday January 21, 2009, I have yet to find any difficulties in using it. Any problems regarding the unit can be easily handled by the company's support.

So far I've worked how to connect it to an Infrared Collision Sensor kit as pictured below

Ill be posting more details on it in later posts, Ill include high def pics using a good friend's DSLR and probably a few videos of it at work.