|
1 | | -# Button and led |
| 1 | +# Button and LED Basics with Arduino |
2 | 2 |
|
3 | | -in this project you will learn the basics of `arduino`. |
4 | | -simulate the project at [led and button](https://wokwi.com/projects/411336385024901121) at wowki . |
5 | | -and don't forget to like ❤️ |
| 3 | +This project introduces the fundamental concepts of Arduino, |
6 | 4 |
|
| 5 | +You can simulate this project online using Wokwi: [Button and LED Simulation](https://wokwi.com/projects/411336385024901121) |
7 | 6 |
|
| 7 | +If you find this helpful, please consider giving it a like ❤️! |
8 | 8 |
|
9 | | -## what you will learn |
10 | | -1. declaring variables |
11 | | -2. reading and writing pins |
12 | | -3. using the serial monitor |
| 9 | +## What You Will Learn |
13 | 10 |
|
14 | | -# Diagram |
15 | | -diagram of the .ino project. |
16 | | - |
| 11 | +This project will guide you through the following essential Arduino concepts: |
17 | 12 |
|
18 | | -## more about the code |
| 13 | +1. **Declaring Variables:** Learn how to create and use variables in your Arduino sketches. |
| 14 | +2. **Reading Digital Input:** Understand how to read the state of a digital input pin connected to a button. |
| 15 | +3. **Writing Digital Output:** Learn how to control a digital output pin connected to an LED. |
| 16 | +4. **Using the Serial Monitor:** Discover how to use the Serial Monitor for debugging and displaying information. |
19 | 17 |
|
20 | | -### serial monitor |
21 | | -a serial monitor mainly used for debging code and printing text |
| 18 | +## Project Diagram |
| 19 | +Circuit setup: |
22 | 20 |
|
| 21 | + |
23 | 22 |
|
| 23 | +## Code |
24 | 24 |
|
25 | | -``` |
26 | | -Serial.begin(9600) |
27 | | -``` |
28 | | -this code will to start the serial monitor. it has to be in the |
29 | | -`setup()` function. |
30 | | - |
31 | | - |
32 | | -To print something in the serial monitor use the `Serial.print()` function. |
33 | | -the code will be something like this: |
34 | | - |
35 | | -``` cpp |
36 | | -void setup() { |
37 | | - Serial.begin(9600); |
38 | | - Serial.print("cool"); |
39 | | -} |
40 | | -``` |
41 | | - |
42 | | -_*NOTE*_: `Serial.print()` will print in the same line and `Serial.printnl()` will print on a new line. |
43 | | - |
44 | | - |
| 25 | +Let's dive deeper into the code elements: |
45 | 26 |
|
| 27 | +### Serial Monitor |
46 | 28 |
|
47 | | -### Pinmode (input and output) |
48 | | -To turn on a led or check if a button is pressed or not we use inputs and outputs. ***Outputs*** are LED, screen, buzzer's. And ***Inputs*** are buttons, switches, etc |
| 29 | +The Serial Monitor is an tool for debugging your Arduino code and displaying text information from your board to your computer. |
49 | 30 |
|
50 | | -to set a pin as a input/output we use `pinMode()` function. |
51 | 31 | ```cpp |
52 | | -pimMode(pin_number, Value) //value can be Input or Output |
53 | | -// and pin_number will be the number of the pin that the input/output is plugged into |
| 32 | +Serial.begin(9600); |
54 | 33 | ``` |
| 34 | +by using the code given, we can set up serial communication. it's recommended to run it inside of the ***setup*** function as it's only need to be run once: |
55 | 35 |
|
| 36 | +```cpp |
| 37 | +void setup() |
| 38 | +{ |
| 39 | + Serial.begin(9600); |
| 40 | +} |
| 41 | +``` |
0 commit comments