Skip to content

Problem with analogIn Matrix portal, latest circuit python #5440

@martingosnell

Description

@martingosnell

Can someone please help, I have latest CircuitPython 7.0 (downloaded 8-Oct-2021) and MU 1.1.0beta5
I want to make a simple analog data logger on Matrix Portal M4 using a while loop and analogio.AnalogIn
I get the ValueError A1 in use
Here's the code with no while loop but A1 value request twice, the second time causes the issue.
I through in some prints and a sleep in case there needed to be time to reset the pins.. please help

import analogio
import board
import time
from board import *

#while True:
print("Hello 1")
adc1 = analogio.AnalogIn(A1)
val = adc1.value
print(val)
print("Hello 2")
adc2 = analogio.AnalogIn(A2)
val = adc2.value
print(val)
time.sleep(1)
print("Hello 1")
adc1 = analogio.AnalogIn(A1)
val = adc1.value
print(val)

Gives ...

soft reboot

Auto-reload is on. Simply save files over USB to run them or enter REPL to disable.
code.py output:
Hello 1
19968
Hello 2
15104
Hello 1
Traceback (most recent call last):
File "code.py", line 17, in
ValueError: A1 in use

Code done running.

Originally posted by @martingosnell in #3552 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions