Arduino Uno Introduction: Difference between revisions
Jump to navigation
Jump to search
(Created page with "= Light up LED 13 on an Arduino Uno = * Open the Arduino IDE and create a new sketch. * In the sketch, write the following code: ``` void setup() { pinMode(13, OUTPUT); } void loop() { digitalWrite(13, HIGH); delay(1000); digitalWrite(13, LOW); delay(1000); } ``` * This code sets pin 13 as an output using the `pinMode()` function in the `setup()` function. * In the `loop()` function, it turns the LED on by setting pin 13 to `HIGH` using the `digitalWrite(...") |
No edit summary |
||
| Line 5: | Line 5: | ||
* In the sketch, write the following code: | * In the sketch, write the following code: | ||
<syntaxhighlight lang="c++"> | |||
void setup() { | void setup() { | ||
pinMode(13, OUTPUT); | pinMode(13, OUTPUT); | ||
| Line 16: | Line 17: | ||
delay(1000); | delay(1000); | ||
} | } | ||
</syntaxhighlight> | |||
* This code sets pin 13 as an output using the `pinMode()` function in the `setup()` function. | * This code sets pin 13 as an output using the `pinMode()` function in the `setup()` function. | ||
| Line 41: | Line 42: | ||
* In the sketch, write the following code: | * In the sketch, write the following code: | ||
<syntaxhighlight lang="c++"> | |||
void setup() { | void setup() { | ||
pinMode(13, OUTPUT); | pinMode(13, OUTPUT); | ||
| Line 52: | Line 53: | ||
delay(1000); | delay(1000); | ||
} | } | ||
</syntaxhighlight> | |||
* This code sets pin 13 as an output using the `pinMode()` function in the `setup()` function. | * This code sets pin 13 as an output using the `pinMode()` function in the `setup()` function. | ||
Revision as of 21:26, 23 April 2023
Light up LED 13 on an Arduino Uno
- Open the Arduino IDE and create a new sketch.
- In the sketch, write the following code:
void setup() {
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}
- This code sets pin 13 as an output using the `pinMode()` function in the `setup()` function.
- In the `loop()` function, it turns the LED on by setting pin 13 to `HIGH` using the `digitalWrite()` function, waits for a second using the `delay()` function, turns the LED off by setting pin 13 to `LOW`, and waits for another second.
- Verify that your Arduino Uno board is connected to your computer and select the correct board and port under the "Tools" menu.
- Upload the sketch to the Arduino Uno board by clicking on the "Upload" button.
- Once the sketch is uploaded, the LED connected to pin 13 should start blinking on and off every second.
Light up a LED connected to Pin 13 on the Arduino Uno
- To light up an LED connected to pin 13 on an Arduino Uno board, you can follow these steps:
- Connect the positive (anode) leg of the LED to pin 13 on the Arduino Uno board.
- Add a 300 Ohm resistor in series
- Connect the negative (cathode) leg of the LED to the GND pin on the Arduino Uno board.
- Open the Arduino IDE and create a new sketch.
- In the sketch, write the following code:
void setup() {
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);
}
- This code sets pin 13 as an output using the `pinMode()` function in the `setup()` function.
- In the `loop()` function, it turns the LED on by setting pin 13 to `HIGH` using the `digitalWrite()` function, waits for a second using the `delay()` function, turns the LED off by setting pin 13 to `LOW`, and waits for another second.
- Verify that your Arduino Uno board is connected to your computer and select the correct board and port under the "Tools" menu.
- Upload the sketch to the Arduino Uno board by clicking on the "Upload" button.
- Once the sketch is uploaded, the LED connected to pin 13 should start blinking on and off every second.