Microblogi: A very long article Wikipedia article on the orientation of toilet paper [7. kes klo 22:52] [V]

Perjantai, 2. joulukuuta 2011

Don't Forget pinMode()

Käännös: [ Google ]

Kategoriat: [ Askartelu/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.

[ Postattu 2. joulukuuta 2011 klo 16.38 | ei kommenttia | ]