Although some reflection reveals that in reality it is not easy either: a window won’t stay open or shut without a hook, nor a door…
Receiving a signal from a button on an Arduino (Lilypad) is just a bit more complicated than the Boolean (TRUE - FALSE) character found in the laptop
A button on the ARDUINO (or comparable) is read in a digital input port registering either a HIGH or a LOW (being either a connection to 5V or to the Ground GND). So a button has three wires! Two wires to 5V and GND respectively and one to the digital input port.
Also: the button needs a resistor (otherwise there might start running a current and you have a short circuit!). You have to make “the standard” state of a port either a HIGH or LOW, and the non standard, pushed, state where the button connects to the reverse but this last connection through the resistor (10K).
When you make connection only to the HIGH for example through the resistor, then the LOW state might become HIGH too, because it is not kept LOW. This gives erratic (artistic) behaviour! (Ever waked up at night because of an unsecured windowmaking lot’s of noise?)
See all this explained much more technically:
http://www.arduino.cc/en/Tutorial/Button
This is not at all difficult, but just a bit more complicated then you would think, seeing a light switch in a lamp.
Details:
in this link
http://www.lulu.com/items/volume_63/1108000/1108699/4/print/ARDUINO_NOTEBOOKv6.pdf
i came across an important remark, apparently saving the trouble of putting the pullup resistors, because the input port is already protected:
“Arduino digital pins default to inputs, so they don’t need to be explicitly declared as inputs with pinMode(). Pins configured as INPUT are said to be in a high-impedance state.
There are also convenient 20KΩ pullup resistors built into the Atmega chip that can be accessed from software. These built-in pullup resistors are accessed in the following manner:
pinMode(pin, INPUT); // set ‘pin’ to input
digitalWrite(pin, HIGH); // turn on pullup resistors
Pullup resistors would normally be used for connecting inputs like switches. Notice in the above example it does not convert pin to an output, it is merely a method for activating the internal pull-ups.”
more interesting stuff on the pull-up: (apparently the above is partially copied from this source or the other way around:)
http://www.arduino.cc/en/Tutorial/DigitalPins
a very extended bunch of ARDUINO things:

0 comments:
Post a Comment