Basic Sketches

We will start with the most basic sketches. Although trivial on the surface they will shed some light on behavior that might be unexpected for all but the most experienced Arduino experts.

The most simple sketch that you can implement is the „bare minimum“ sketch.

void setup() { }
void loop() { }

It seems to do „absolutely nothing“. So warm up your Arduino and see what happens.

First LEDs 0 and 1 start to flicker / light up. This is because serial communication is happening through these pins. The computer is transmitting data to the Arduino and the LEDs start to light up. You will notice some differences between LED 0 and LED 1. LED 0 is connected with pin 0. This is where the Arduino listens to the computer. This pin is driven by the serial interface. The FTDI chip is „decoupled“ with a 1k resistor. LED 0 gets driven by the serial interface chip through two 1k resistors in series. LED 1 on the other hand is connected to pin 1. Pin 1 is where the Arduino sends to the computer. This pin is driven by the Arduino. Thus LED 1 is driven with only 1k in series. Consequently LED 1 will be brighter than LED 0.
You can also see that LED 13 lights up shortly. This is the bootloader indicating that it is present.
Once the upload process is finished LED 0 will stay „on“ but not with full brightness. This is because the serial interface will default to high, driving the LED through the two 1k series resistors. LED 1 will be „on“ but very dim. This is because this line is tied with a „pullup“ resistor to 5V. Again this is caused by the serial interface.
One interesting issue is why serial communication works at all with this setup. For pin 1 the additional load caused by LED 1 will not significantly alter the signal seen by the serial interface. However LED 0 and its series resistor will put significant load on the serial signal since this has 1k impedance. The forward voltage of LED 0 is about 1.8V. The two 1k resistors are a 1:1 voltage divider. Therefore a 5V signal of the serial interface will result in 1.8V + (5V-1.8V)/2 = 3.4V at pin 0. According to the datasheet 3.4V is interpreted as a digital high. Hence serial communication still works.
Have a look at the simplified schematic to better understand what is going on here.

Simplified Arduino Schematics

Simplified Arduino Schematics

With the next “basic” sketch we will investigate what happens if all pins are set to “High Z”.

Once you are through all the basic sketches you may want to continue with the entertaining basic effects.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.