Thursday, May 28, 2009

Analog input lab


After doing the lab using the potentiometer, I tried hooking up a flex sensor to the circuit using the same code, to see if I could use the flex input to dim and brighten the LED. Testing the flex senor, I found the input that I read from it to be very small in range, from about 1017 to 1023, with occaisional very small outliers like 10 or 107. Because of the tiny range, bending the flex sensor made no visible difference in the output of the LED. I decided to try and just make the flex sensor turn the LED on and off. Because of the erratic nature of the flex sensor readings, I decided to use a for loop to generate an average of many readings in each program loop. The for loop takes 30 readings and finds the mean average, and the program then either powers the LED or not, depending on weather or not there is a discernable bend in the sensor.
Here's the code I ended up with:
int flexPin = 0;
int flexValue = 0;
int led = 9;
int flexSum = 0;
int flexAverage = 0;
void setup(){
Serial.begin(9600);
}
void loop(){
flexSum = 0;
for(int j = 0; j < flexvalue =" analogRead(flexPin);" flexsum =" flexSum" flexaverage =" flexSum/30;">

Tuesday, May 26, 2009

Zombie Threat Indicator

Decided to have a little fun with the circuit from lab three. I had a board game running around, with zombies and little men with shotguns as playing pieces. I attached foil to the bases of the game pieces in place of the switch. Now, when the zombie and human game pieces touch, the yellow LED switches off and the red LED switches on, obviously to indicate the imminent threat of zombie infection.

Lab 3


After getting help in class and completing lab 2 (I think my voltage regulator was backwards originally), I have now completed lab three as well. Having a bit of a background in computer science, I was astonished by how simple it is to program the Arduino. Granted I am no master yet, but since digital input and output is the primary use of the device, it seems like it's only a matter of expanding the existing syntax and adapting it to different input and output components and devices. The one part of the lab I am unsure about is the use of the 10k Ohm resistor . Is this an example of a pull-down resistor? Being able to measure voltage using the multimeter during this lab greatly improved my understanding of how components affect voltage within a circuit. I am currently brainstorming how one would use an Arduino with a large number of LED's or other components in a circuit, especially if one wanted to access these components independently.

Thursday, May 21, 2009

First Labs or, The Joy of Discovery

I walked into the NYU computer store today and decided to buy all my own stuff, so I would be able to work on labs at home given my busy schedule which doesn't always align with lab hours. Excited to try it out, I ran home, unpacked a tool kit, a supplementary tool kit, and Lab Kit 1. For the first lab, merely setting up the breadboard with a voltage regulator, everything seemed peachy. I clipped and stripped the wires and set up yhr breadboard as illustrated:

Starting Lab 2, I picked up my handy Multimeter to measure the voltage across components. This is where things started to go downhill. I wasn't sure of exactly the best method for measuring voltage "across a component". I lined up the black wire of the multimeter with an exposed bit from a black "ground" wire on my breadboard. I did the same for red. I got a reading around 14.80. Based on the lab instructions I should have had a reading of 0.5 from power to ground, due to my 5 volt regulator. Puzzled, I placed the multimeter needles on either side of the regulator, and a blue spark came out. I'm relatively certain this wasn't supposed to happen. I replaced the regulator with a fresh one, and pressed on despite the descrepancy.

I took a big, shiny red button out of the lab kit, stripped two lengths of green wire and soldered them to the underside. It looked pretty peachy, until I tried to bend the wires and get them into the breadboard, and one of them snapped. I think I may have been using the supplied wire stripper improperly. Still undaunted, I remembered my supplemental tool kit came with a desoldering pump!

I held my iron to the snapped bit of soldered-in wire, and attempted the pump operation several times, without success. At this point the button seemed to come apart of its own accord. My own uninformed theory is that the soldering iron was on it for too long, and the heat disagreed with the metal bits in the button.

I picked a smaller, much less impressive looking button from the kit, and managed to get two wires on it without a problem, although they looked dangerously close to eachother, based on the proximity of the button's contact points.

I put together the rest of the circuit, using what the internet led me to believe was a 220-Ohm resistor (red, red, brown, silver). Looking at all my wires and components in the right places, with a smile on my face, I plugged the thing in and hit the button!

And nothing happened. The cherry red LED refused to light. I noticed that I had sort of melted the two wires leading to the button together. I also realized that I have no idea what I am doing.

However, I believe that the learning process is the process of failing less and less miserably as time goes on, and I plan on spending much of the day in the lab tomorrow doing just that.