Sunday, May 18, 2008

Arduino Simplicity Part II-a

I thought this was going to be really simple, but just doing the schematic has required me to learn a bit of EAGLE CAD which allows me to draw schematics. I'm sorry this one isn't quite ideal.

One thing to note on the previous blog is that because of space on my protoshield, I'll be using pin 7 for input instead of pin 2.

Here's the schematic of the "sensor" side of the circuit we'll be building:

When the switch is open, current has only one path - between +5V and PIN7. This is when PIN7 will read HIGH in the code. When you press the button, current is able to go from +5V to ground (the button is connected to ground), and so PIN7 will now read LOW. If things were reversed, and the button were connected to +5V and we connected R1 to ground, it would work similarly, except PIN7 would always read LOW unless the button were pushed.

What's interesting, though, is that if we remove R1 and the ground there, PIN7 fluctuates between high and low. It's a very odd phenomenon, and I'm not quite sure I understand it (the current has to be coming from somewhere, right?) If you use a similar circuit and watch analog values when the switch is open, the values coming back vary wildly.

In the next segement, I'll show you how to wire this up on a protoshield. After that, I'll show you how to wire it up on a learning lab. I wanted to show it on a breadboard, complete with the ground resistors, but I couldn't find pushbuttons.

0 comments: