You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/micropython/03.micropython/01.basics/00. digital-io/digital-io.md
+11-11Lines changed: 11 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,8 @@
1
1
---
2
-
3
-
featured: micropython-101
4
-
title: '2. Micropython Basics - Digital I/O'
5
-
description: 'Learn the basics for loops on MicroPython.'
2
+
title: 'Digital I/O'
3
+
description: 'Learn about digital I/O with MicroPython.'
6
4
author: 'Pedro Lima'
7
-
hero_image: "./hero-banner.png"
8
-
5
+
tags: [MicroPython, Digital I/O]
9
6
---
10
7
11
8
Digital pins are fundamental for interacting with the physical world using your Arduino board. In this chapter, we'll explore how to use digital pins in MicroPython to:
@@ -18,15 +15,19 @@ Digital signals have two distinct values:
18
15
-**HIGH (1)**: Represents a voltage level close to the board's operating voltage (e.g., 3.3V or 5V).
19
16
-**LOW (0)**: Represents a voltage level close to 0V (ground).
20
17
21
-
Although they can only represent two states, digital signals are highly useful. Being binary in nature, they directly interface with microcontrollers and processors, making them ideal for tasks requiring fast, on/off communication, such as reading sensors or controlling simple outputs. Their simplicity also gives them a natural resilience to electrical noise, as noise only disrupts digital signals when it is strong enough to cross the threshold between HIGH and LOW states. This makes them reliable for clear, consistent communication in various environments.
18
+
Although they can only represent two states, digital signals are highly useful. Being binary in nature, they directly interface with microcontrollers and processors, making them ideal for tasks requiring fast, on/off communication, such as reading sensors or controlling simple outputs. Their simplicity also gives them a natural resilience to electrical noise, as noise only disrupts digital signals when it is strong enough to cross the threshold between HIGH and LOW states. This makes them reliable for clear, consistent communication in various environments, compared to analog signals.
19
+
20
+
## Requirements
21
+
22
+
22
23
23
24
## Digital Outputs
24
25
25
-
To control digital outputs in MicroPython, we use the `Pin` class from the `machine` module. Setting a pin as an output allows you to control devices like LEDs, relays, or other actuators.
26
+
To control digital outputs in MicroPython, we use the `Pin` class from the `machine` module. Setting a pin as an output allows us to control devices like LEDs, relays, or other actuators.
26
27
27
-
###Code Example: Blinking an LED
28
+
## Code Example: Blinking an LED
28
29
29
-
Let's create the classic "Blink" example, where we turn an LED on and off at regular intervals.
30
+
For this exercise, we will use the "Blink" example, where we turn an LED on and off at regular intervals.
30
31
31
32
**Components Needed:**
32
33
@@ -72,7 +73,6 @@ while True:
72
73
- The loop repeats indefinitely, causing the LED to blink.
73
74
74
75
75
-
76
76
## Digital Inputs
77
77
78
78
Reading digital inputs allows your program to respond to external events, like button presses or sensor signals. In MicroPython, we use the `Pin` class to set up pins as inputs, and we can specify pull modes to stabilize the input readings.
0 commit comments