ao analog out
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- jknoxhcsd
- Posts: 18
- Joined: Mon Nov 04, 2019 1:48 pm
ao analog out
I am having issues with writing an analog out to A0 in makecode. My goal was to have students write out an analog signal value to a RGB LED to show them how an analog signal works as well as how color works. Anytime we write to A0 in makecode the CPX freezes up and the lights turn to red and blue. We do not have a resistor between the LED and A0 as the output on A1 and A2 are only about 20mA and work great. Ideas? The RGB LED is on a breadboard and the pins are wired directly to the legs of the LED through the breadboard.
- jps2000
- Posts: 811
- Joined: Fri Jun 02, 2017 4:12 pm
Re: ao analog out
Teaching students to use a LED without a resistor in series is not so a good idea
- jknoxhcsd
- Posts: 18
- Joined: Mon Nov 04, 2019 1:48 pm
Re: ao analog out
True, but the pins only put out about 20mA and would not work at all with a resistor in series. Now, do you have anything of value to add to the conversation?
- jps2000
- Posts: 811
- Joined: Fri Jun 02, 2017 4:12 pm
Re: ao analog out
Small resistors like 100 ohms will work.
It will prevent high currents in the moment of switching 20mA is max permanent current.
It may be that those spikes cause a drop in vcc.
So check if the problem is there wihout LEDs connected. ( Check if the loop is still running elsewhere)
How shall someone contribute? You say it halts. There are so many causes. And I am not familiar with makecode.
It will prevent high currents in the moment of switching 20mA is max permanent current.
It may be that those spikes cause a drop in vcc.
So check if the problem is there wihout LEDs connected. ( Check if the loop is still running elsewhere)
How shall someone contribute? You say it halts. There are so many causes. And I am not familiar with makecode.
- adafruit_support_bill
- Posts: 88088
- Joined: Sat Feb 07, 2009 10:11 am
Re: ao analog out
That may be the maximum that the pin is rated for, but it is not actively current limited. Exceeding the current rating for a pin can damage the pin.True, but the pins only put out about 20mA
Not true at all. LEDs will illuminate with well under 20mA.and would not work at all with a resistor in series.
- jknoxhcsd
- Posts: 18
- Joined: Mon Nov 04, 2019 1:48 pm
Re: ao analog out
Thank you for the explanation. I originally had kids start with 220 Ohm resistors (that is what I had available) and the LED wouldn't light up. I almost always have a resistor in the circuit but this one I did not because I had read that the pin was limited to 20mA anyway. My assumption (wrong) was that there must be some type of internal resistor on the pin limiting the current out. Still having issues with A0 though.
- adafruit_support_bill
- Posts: 88088
- Joined: Sat Feb 07, 2009 10:11 am
Re: ao analog out
If you post the code you are using and some photos of your setup we can take a closer look.
- jknoxhcsd
- Posts: 18
- Joined: Mon Nov 04, 2019 1:48 pm
Re: ao analog out
Just with an analog pin out with nothing attached I get this happening. Clearly I'm doing something wrong or am completely misunderstanding the purpose of the analog out. I did update the boot loader on the CPX.
- adafruit_support_bill
- Posts: 88088
- Joined: Sat Feb 07, 2009 10:11 am
Re: ao analog out
Have you seen this behavior on more than one of your Circuit Playground boards?
- jknoxhcsd
- Posts: 18
- Joined: Mon Nov 04, 2019 1:48 pm
Re: ao analog out
Several yes. Seems to be universal.
- adafruit_support_bill
- Posts: 88088
- Joined: Sat Feb 07, 2009 10:11 am
Re: ao analog out
Let me check with our MakeCode experts . . .
- jknoxhcsd
- Posts: 18
- Joined: Mon Nov 04, 2019 1:48 pm
Re: ao analog out
Thank You!!! Purely speculation on my part but pin A0 is "true analog out" whatever that means (I am sure it is digital, just with a higher resolution of outputs and not pwm?) vs the PWM of the other pins. This is causing some type of problem with the code behind the scenes maybe? (wild speculation on my part) My other question is why pin A3 isn't listed as an analog out in Makecode when it is also supposed to be capable of analog out. For anyone else reading this, pins A1 and A2 (and supposedly A3) are actually pwm pins that are only analog in the sense of a pwm average voltage. Pin A3 is not listed as an analog pin out in Makecode.
- adafruit2
- Posts: 22144
- Joined: Fri Mar 11, 2005 7:36 pm
Re: ao analog out
yeah A0 is special! its not actually a PWM out so please use the other pads
- jknoxhcsd
- Posts: 18
- Joined: Mon Nov 04, 2019 1:48 pm
Re: ao analog out
Is there a reason A3 is not listed in makecode as analog out? Could the blocks be changed to list A1, A2, and A3 vs 0, 1, 2? It would be nice to have 3 pins for color mixing.
- adafruit2
- Posts: 22144
- Joined: Fri Mar 11, 2005 7:36 pm
Re: ao analog out
do you mind posting a screenshot of what you're referring to?
Please be positive and constructive with your questions and comments.