Flash_BRIGHT © GPL3+

Why you can blank, void setup()

  • 1 comment
  • 4 respects

Components and supplies

About this project

I am a creative Arduino user and have a desire to build experiments using a number of different boards in a line. Some people believe you cannot connect more than two Arduinos.

UPDATE 20/09/2019: I have successfully linked two using my own device and program. I am now working to include a 3rd Arduino. Once I have achieved that, I should be able to link 5 easily. If I achieve 5, that will prove that you can link an unlimited number of Arduino/prototyping boards as you wish. Not merely linearly, but in a networked system, if desired. Complicated Arduino macro-robotics, here we come.

For 'this' program and board.

I realised very quickly that when only one LED at a time is flashing I don't need to connect a resistor to each LED, but need only one, if I connect it via -ve/GRD. Saves clutter, work and resistors.

I had in the back of my mind that writing ten int statements at the beginning seemed to be repeated in my for loop and why did I need to do that? [See the usual method, compared with my streamlined method in the software section below].

I had noted that that's what everyone does, but was it just 'usual practice', or not, actually, necessary.

So, when I built this project, a well known circuit (except I changed the resistor sequence), I got one BRIGHT flashing LED and nine almost invisible ones, for reasons I still do not fully understand, since they were obviously getting a voltage, but much less than the expected 5v.

The project photo demonstrates the dim(top row of LEDs) and BRIGHT LED, including board and layout [Fritzing diagram below].

Still loath to just write in the other nine int statements, I spent hours over three days before I was sure it was not hardware related - like duff LEDs.

Then I spent hours on the last day trying to work the software - still did not want to write in those pesky int statements..

Eventually, I decided to see if void setup() is absolutely needed and just deleted it. Of course, it did not work at all, since it is a requirement.

In the back of my mind was a possible fix, but, after experimenting, it meant me declaring the pinMode(pin, OUTPUT); instruction in both setup and loop functions. In fact, a bit of experimenting proved that I could leave void setup() entirely empty, so I needed only to declare it once inside the void loop() function.

So I wrote:

void setup() {}

Which Verify proved is acceptable.

Now all the LEDs flash BRIGHT, instead of one bright and nine dim..

Q. Does anyone know why a low voltage between 0v and 5v happens when you choose not to put the other 9 int declarations at the beginning?


Learning project, why you can blank void setup()
// Created 8th February 2019 by Neil Doherty

'normal' presentation:
int ledPin3 = 3; // Usual assigned designated output pins
int ledPin4 = 4; 
int ledPin5 = 5;
int ledPin6 = 6;
int ledPin7 = 7;
int ledPin8 = 8;
 int ledPin9 = 9;
int ledPin10 = 10;
int ledPin11 = 11;
int ledPin12 = 12;
const int delayperiod = 30;

then we would have:

void setup () {
    pinMode(ledPin3, OUTPUT); // Usual pinMode 
    pinMode(ledPin4, OUTPUT);
    pinMode(ledPin5, OUTPUT);
    pinMode(ledPin4, OUTPUT);
    pinMode(ledPin5, OUTPUT);
    pinMode(ledPin6, OUTPUT);
    pinMode(ledPin7, OUTPUT);
    pinMode(ledPin8, OUTPUT);
    pinMode(ledPin9, OUTPUT);
    pinMode(ledPin10, OUTPUT);
    pinMode(ledPin11, OUTPUT);
    pinMode(ledPin12, OUTPUT);

// Instead of all that, delete all of the above and use:

// Created 8th February 2019 by Neil Doherty
// instead of making eleven int statements, only two are used.

const int delayPeriod = 30; // uses less memory than int.

/* However, by creating void setup() as an empty statement, we save space in the Arduino memory by using the lowest possible number of int statements, because they are not in the program twice, which also enables the LEDs to Flash BRIGHT, instead of 'glinting'.
void setup() {}

void loop() {

 for (int pin = 4; pin < 14; pin++)
    pinMode(pin, OUTPUT); // declare pinMode once in the loop, here.
    digitalWrite(pin, HIGH);
    digitalWrite(pin, LOW);
     for (int pin = 13; pin >  5; pin--) // 13 and 5 used here so that
     // the outer LEDs are not double-flashed unnecessarily
    digitalWrite(pin, HIGH);
    digitalWrite(pin, LOW);



flash BRIGHT
An image of an easy to copy circuit.
Flash bright i4t91hecva



  • 0 projects
  • 1 follower

Additional contributors

  • General learning by Broadcast knowledge

Published on

February 8, 2019

Members who respect this project


and 3 others

See similar projects
you might like

Similar projects you might like

Programming 8x8 LED Matrix

by SAnwandter1

  • 122 respects

Programming 4 Digit 7 Segment LED Display

by SAnwandter1

  • 66 respects

10 Awesome Beginner Arduino Projects

by RoyTobby

  • 1 comment
  • 29 respects

NeoPixel LEDs: Arduino Basics

by Alex Glow

  • 1 comment
  • 48 respects

Buzzer Alarm System With Help Of Arduino

by Team ONYX

  • 24 respects

Control your Light System Using Smart Phone

Project tutorial by Ahmed Yassin

  • 60 respects
Add projectSign up / Login