# Lesson 2: Multiple LEDs and Variables

### The Circuit

Let’s put together several LEDs in a row. Use pins 5 – 13 as the inputs.

Think about how the single circuit diagram and how the real circuit looks like when put together. Now, do the same for a total of 9 LEDs.

We can use variables in place of explicitly writing values (highlighted in RED in the code). Look at how we can use variables in place of just using the number "10" for pin 10. Look at how we can use variables to indicate the number of seconds.

#### Definition:

Variable – A variable is a symbolic name for some piece of data or value. A variable “stands in” for possible values and can change values during the execution of a computer program.

Variables are associated with a data type, which describes the type of data value it can hold (integer, real number, Boolean, etc).

### Using Variables

`/* * Blink * ===== * * Filename: Blink.ino * * Description: * This sketch attaches LEDs to the Arduino board. It will turn on and off. * This sketch shows an example of using variables in place of * writing the LED pin number. * * Inputs: None * * Outputs: LED light * * Created By: D. Lee * Date: July 2014 * */ // define our variables for each of the LEDsint ledPin = 10;  // Pin 10// Number of seconds for delay (ms)int numSeconds1 = 1000;  // 1 secondint numSeconds2 = 2000;  // 2 secondsint numSeconds3 = 3000;  // 3 secondsvoid setup(){  // Initialize each LED as output  pinMode(ledPin, OUTPUT);}void loop(){  // Write to our LEDs  digitalWrite(ledPin, HIGH); // Turn on the LED  delay(numSeconds1);         // Stay on for numSeconds1  digitalWrite(ledPin, LOW);  // Turn off the LED  delay(numSeconds2);         // Stay off for numSeconds2}`

We can use variables in place of explicitly writing values (highlighted in RED in the code). Look at how we can use variables in place of just using the number "10" for pin 10. Look at how we can use variables to indicate the number of seconds.

#### What are some of the advantages of using variables like this?

• [ List some advantages ]
• [ List some advantages ]
• [ List some advantages ]

#### Variable Names

[ Describe this section ]