Microblog : A very long article Wikipedia article on the orientation of toilet paper [7 jun à 22:52] [R]

Vendredi, 2 décembre 2011

Don't Forget pinMode()

Traduction: [ Google | Babelfish ]

Catégories : [ Bricolage/Arduino ]

I spent hours with a friend trying to solve the following problem: an LED and a 430R resistor are connected to the pin of an Arduino (actually an RBBB powered with 3.3 V). Using digitalWrite(pin, HIGH) it did light the LED, but it was very dim. What was more weird, is that the pin was showing only 1 V instead of 3.3 V. After two hours of scratching our heads, I looked up on Google and found the answer: “don't forget to call pinMode(pin, OUTPUT)…”

At boot time, the pins are set as inputs. digitalWrite(pin, HIGH) switches the internal pullup resistor (20K – 50K), which is enough to allows the pin to source a little bit of current at a quite low voltage. It was enough the dimly light the LED, but not enough to get the optocoupler (that was initially connected to the pin) to work properly.

[ Posté le 2 décembre 2011 à 16:38 | pas de commentaire | ]