filmov
tv
Lesson 2: Arduino Foundations, Programming basics using void setup & void loop to make led blink

Показать описание
Tutorial on programming basics and general patterns.
Required Parts:
- Arduino UNO
- USB A / B
- Breadboard
- Two LEDs
- 1 Male/Male Jumper Wire
*note case sensitive syntax highlighting not visible in this description.
void setup (): header function and beginning of the program, followed by curly brackets or braces that signal the body of the header function. Repeated once in the program to define.
void loop (): header function, followed by the same curly braces, and more stuff inside the body. Repeats what you tell it to for the life of the program.
Keyword: A thing built into the C/C++ language and reserved for a specific role.
Statement: Like a line of poem and always ends with ';'. Multiple statements form the body of a header function.
pinMode(): Allows you to tap the many pins of the Arduino board. Always followed by a thing in parentheses; a number, followed by a comma and defined as either an OUTPUT or INPUT.
digitalWrite(): Similar to pinMode parentheses enclose numbers, a comma, and HIGH / LOW rather than INPUT / OUTPUT. digitalWrite (12,LOW); makes pin 12 connected to zero volts. digitalWrite (13,HIGH); makes pin 13 HIGH, or connects it to the Arduino’s 5v.
delay(): This tells the program to stall for a period of time. 1000 milliseconds, or 1 second for this example.
LED: Has a built in resistor to limit the 5v current driven through the LED from ruining the Arduino microcontroller.
Anode: The long end of the LED or resistor that runs power / electricity.
Cathode: The short end of the LED that runs to ground.
CODE SOURCE
void setup()
{
pinMode(12,OUTPUT);
pinMode(13,OUTPUT);
}
void loop()
{
digitalWrite(12,LOW);
digitalWrite(13,HIGH);
delay(200);
digitalWrite(12,HIGH);
digitalWrite(13,LOW);
delay(200);
}
Required Parts:
- Arduino UNO
- USB A / B
- Breadboard
- Two LEDs
- 1 Male/Male Jumper Wire
*note case sensitive syntax highlighting not visible in this description.
void setup (): header function and beginning of the program, followed by curly brackets or braces that signal the body of the header function. Repeated once in the program to define.
void loop (): header function, followed by the same curly braces, and more stuff inside the body. Repeats what you tell it to for the life of the program.
Keyword: A thing built into the C/C++ language and reserved for a specific role.
Statement: Like a line of poem and always ends with ';'. Multiple statements form the body of a header function.
pinMode(): Allows you to tap the many pins of the Arduino board. Always followed by a thing in parentheses; a number, followed by a comma and defined as either an OUTPUT or INPUT.
digitalWrite(): Similar to pinMode parentheses enclose numbers, a comma, and HIGH / LOW rather than INPUT / OUTPUT. digitalWrite (12,LOW); makes pin 12 connected to zero volts. digitalWrite (13,HIGH); makes pin 13 HIGH, or connects it to the Arduino’s 5v.
delay(): This tells the program to stall for a period of time. 1000 milliseconds, or 1 second for this example.
LED: Has a built in resistor to limit the 5v current driven through the LED from ruining the Arduino microcontroller.
Anode: The long end of the LED or resistor that runs power / electricity.
Cathode: The short end of the LED that runs to ground.
CODE SOURCE
void setup()
{
pinMode(12,OUTPUT);
pinMode(13,OUTPUT);
}
void loop()
{
digitalWrite(12,LOW);
digitalWrite(13,HIGH);
delay(200);
digitalWrite(12,HIGH);
digitalWrite(13,LOW);
delay(200);
}