Arduino/Micro/Blink: Difference between revisions
From charlesreid1
No edit summary |
|||
| Line 1: | Line 1: | ||
=Overview= | =Blink: First Pass= | ||
==Overview== | |||
In this article, we go over a simple blink program using the Arduino Micro. This is the same as the [[Hello World Arduino Micro]] circuit, but with the Arduino controlling the voltage of the circuit to make it blink. | In this article, we go over a simple blink program using the Arduino Micro. This is the same as the [[Hello World Arduino Micro]] circuit, but with the Arduino controlling the voltage of the circuit to make it blink. | ||
| Line 5: | Line 7: | ||
In the simple Hello World example, we wanted a constant source of potential, 5 volts, to keep the LED light continuously lit. Now, we want to control the voltage so that we can shut the light on and off. The program we load onto the Arduino microcontroller will allow us to create a logical program to control the voltage. | In the simple Hello World example, we wanted a constant source of potential, 5 volts, to keep the LED light continuously lit. Now, we want to control the voltage so that we can shut the light on and off. The program we load onto the Arduino microcontroller will allow us to create a logical program to control the voltage. | ||
=The Circuit= | ==The Circuit== | ||
The circuit for our blink program is almost exactly the same as for the Hello World program, except now we plug it into a numbered pin on the Arduino board: | The circuit for our blink program is almost exactly the same as for the Hello World program, except now we plug it into a numbered pin on the Arduino board: | ||
| Line 13: | Line 15: | ||
Instead of plugging into the 5V pin, we plug it into the D13 pin. | Instead of plugging into the 5V pin, we plug it into the D13 pin. | ||
=The Program= | ==The Program== | ||
The first half is changing the circuit; the other half is changing the logic. Here's a very simple blink program that's built into Arduino: | The first half is changing the circuit; the other half is changing the logic. Here's a very simple blink program that's built into Arduino: | ||
Revision as of 21:30, 18 July 2015
Blink: First Pass
Overview
In this article, we go over a simple blink program using the Arduino Micro. This is the same as the Hello World Arduino Micro circuit, but with the Arduino controlling the voltage of the circuit to make it blink.
In the simple Hello World example, we wanted a constant source of potential, 5 volts, to keep the LED light continuously lit. Now, we want to control the voltage so that we can shut the light on and off. The program we load onto the Arduino microcontroller will allow us to create a logical program to control the voltage.
The Circuit
The circuit for our blink program is almost exactly the same as for the Hello World program, except now we plug it into a numbered pin on the Arduino board:
Instead of plugging into the 5V pin, we plug it into the D13 pin.
The Program
The first half is changing the circuit; the other half is changing the logic. Here's a very simple blink program that's built into Arduino:
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 13 as an output.
pinMode(13, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(200); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(200); // wait for a second
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(200); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(200); // wait for a second
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(200); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(200); // wait for a second
delay(1000); // wait for a second
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(200); // wait for a second
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(200); // wait for a second
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(500); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(200); // wait for a second
delay(1000); // wait for a second
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(200); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(200); // wait for a second
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(200); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(200); // wait for a second
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(200); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(200); // wait for a second
delay(1000); // wait for a second
}