Skip to content

Commit 3222e42

Browse files
committed
move adc read information
1 parent e965756 commit 3222e42

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

content/micropython/01.basics/05.digital-analog-pins/digital-analog-pins.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,25 @@ There are four methods to use inside the ADC class: `ADC.init`, `ADC.block()`, `
9696

9797
### Analog Read
9898

99-
To read an analog pin, we can use the `ADC.read_u16` command. This reads the specified analog pin and returns an integer in the range 0 - 65535. For this, we need to import `ADC` from the `machine` module.
100-
101-
***Note: This is currently only available on the nightly build***
99+
To read an analog pin, we can use the `ADC.read_u16` command. This reads the specified analog pin and returns an integer in the range 0 - 65535. For this, we need to import `ADC` and `Pin` from the `machine` module.
102100

103101
```python
104-
from machine import ADC
102+
import machine
103+
import time
104+
105+
# Make sure to follow the GPIO map for the board you are using.
106+
# Pin 29 in this case is the "A3" pin on the Nano 33 BLE / BLE Sense
107+
adc_pin = machine.Pin(29)
108+
adc = machine.ADC(adc_pin)
105109

106110
while True:
107-
adc = ADC("A4")
108-
adc.read_u16()
111+
reading = adc.read_u16()
112+
print("ADC: ",reading)
113+
time.sleep_ms(500)
109114
```
110115

116+
***If you are using an [Arduino Nano RP2040 Connect](https://store.arduino.cc/products/arduino-nano-rp2040-connect), you can also do the following: `adc = ADC("A4")`. Check out the example [here](http://localhost:8000/micropython/basics/board-examples#analog-read)***
117+
111118
## PWM (Pulse Width Modulation)
112119

113120
[PWM](/learn/microcontrollers/analog-output) is used to produce analog results with digital means, by switching ON/OFF a signal rapidly.

content/micropython/01.basics/06.board-examples/board-examples.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,20 @@ Before you start using the board's pins, it might be a good idea to check out th
4949
| D20/A6 | GPIO36 | ADC/NINA-W102 |
5050
| D21/A7 | GPIO35 | ADC/NINA-W102 |
5151

52+
### Analog Read
53+
54+
***Note: This is currently only available on the nightly build***
55+
56+
To read an analog pin, we can use the `ADC.read_u16` command. This reads the specified analog pin and returns an integer in the range 0 - 65535. For this, we need to import `ADC` from the `machine` module.
57+
58+
```python
59+
from machine import ADC
60+
61+
while True:
62+
adc = ADC("A4")
63+
adc.read_u16()
64+
```
65+
5266
### Sensors
5367

5468
#### IMU (LSM6DSOX)
@@ -474,6 +488,10 @@ In the MicroPython port of the Nano 33 BLE board, the pinout is the same as the
474488
| D20/A6 | 28 |
475489
| D21/A7 | 3 |
476490

491+
### Analog Read
492+
493+
***The following example is currently only possible with the nightly build***
494+
477495
### LED Control
478496

479497
There are 3 different LEDs that can be accessed on the Nano 33 BLE: **RGB, the built-in LED** and the **power LED**.

0 commit comments

Comments
 (0)