0

ItsyBitsy nRF52840 + CircuitPython + analog outputs
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

ItsyBitsy nRF52840 + CircuitPython + analog outputs

by rlaferla on Sun Mar 14, 2021 10:57 pm

First, I hope this is the correct forum for the nRF52840. If not, tell where to post my question.

Secondly, I'm relatively new to circuits so I may be using the wrong approach. If so, let me know what I should be doing.

PROBLEM:

I have a basic circuit with a LED and 47 ohm resistor. I want to vary the brightness using an analog output. I get an error that AnalogOut is not supported. What do I do?

Code: Select all | TOGGLE FULL SIZE
import board
import analogio
import time

led = analogio.AnalogOut(board.A0)
while True:
    # Count up from 0 to 65535, with 64 increment
    for i in range(0, 65535, 64):
        led.value = i
        print(i)


Code: Select all | TOGGLE FULL SIZE
code.py output:
Traceback (most recent call last):
  File "code.py", line 5, in <module>
RuntimeError: AnalogOut functionality not supported

rlaferla
 
Posts: 10
Joined: Tue Feb 07, 2017 11:50 am

Re: ItsyBitsy nRF52840 + CircuitPython + analog outputs

by dastels on Mon Mar 15, 2021 5:27 pm

From my recent digging into this, it seem that the nRF52840 does not have a DAC, so no true analog out. Using PWM to control LED brightless is actually a better approach since the LED will stop working when the voltage across it gets too low. With PWM it's being switch between fill on and full off, your eye averaging the relative on time and off time to a brightness.

Dave

dastels
 
Posts: 6431
Joined: Tue Oct 20, 2015 3:22 pm

Please be positive and constructive with your questions and comments.