By now we have investigated what happens if we set all pins to high Z, pull up or low. We conclude the basic sketches by setting all pins to high.
// // www.blinkenlight.net // // Copyright 2011 Udo Klein // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see http://www.gnu.org/licenses/ // This sketch will set all outputs to high. void setup() { for (uint8_t pin=0; pin<20; ++pin) { pinMode(pin, OUTPUT); digitalWrite(pin, HIGH); } } void loop() { }
All LEDs light up. Bright!
does not work with leonardo …. some light’s not high. and not in correct order. 😦
I do not own a Leonardo. Can you please give a little bit more details such that I can investigate this? Maybe a picture?
Sorry here! All lights high … https://twitter.com/hifigraz/status/286523857031012353
and I think 16 and 15 are more 20 and 19 ….
finally … counting from 1 to 20
Thanks for the video. This makes the issue crystal clear. I searched a little bit and found this one: http://provideyourown.com/2012/arduino-leonardo-versus-uno-whats-new/:
Since the original Arduino maps A0 to D14, A1 to D15 … A5 to D19 it follows that D14 … D17 are not connected to any LEDs of the shield. This explains the effect exhibited in your video. So you have to change your code to count 0, 1, 2, …, 12, 13, 18, 19, …, 23 instead of 0 … 19.
hey thank you, that was fast 😉
Here is an example how such a mapping might be implemented. The led_to_pin() function does the trick.
Hi! Here https://twitter.com/hifigraz/status/286523857031012353 All Lights high example!
There was a little error in the comments of your code.
Just right before the “setup()”
Error:
“// This sketch will set all outputs to low.”
Should be:
“// This sketch will set all outputs to high.”
Made me confused for a moment.
No big deal really. In fact, it’s a very small deal.
But the correction makes your article more perfect! 🙂
Thanks for noticing this bug. I fixed it.