-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
C Programming for Arduino
By :
We are going to create a very small library and test it with a basic circuit including six LEDs that are not multiplexed.
Here is the circuit. It basically contains six LEDs wired to Arduino:

Six LEDs wired to the board
The circuit diagram is shown as follows:

Another diagram of the six LEDs wired directly to Arduino
I won't discuss the circuit itself, except to mention that I put in a 1 kΩ resistor. I took the worst case where all LEDs would be switched on at the same time. This would drive a lot of current, and so this acts as security for our Arduino. Some authors wouldn't use it. I'd prefer to have some LEDs dimming a bit in order to protect my Arduino.
Here is code for lighting up the LEDs according to some patterns, all hardcoded. A pause is made between each pattern display:
void setup() {
for (int i = 2 ; i <= 7 ; i++)
{
pinMode(i, OUTPUT);
}
}
void loop(){
// switch on everything...
Change the font size
Change margin width
Change background colour