I get a ValueError: pin already used for adc if i call adc = ADC(pin) a second time in a other code part... (I'm on LoBo firmware)
What's a best practise in this case?
Should i made a instance of defaults pins somewhere and (re-)use the instances everywhere? Where is a common place for this?
Is there a "internal registry" of all Pin() instances?!?
resuse pin ?!?
Re: resuse pin ?!?
You can create ony one ADC instance on any pin. If you don't need it anymore, free it with adc.deinit(), than you can use the same pin again (for adc or any other purpose).
Read the ADC Wiki for more details.
Read the ADC Wiki for more details.
Re: resuse pin ?!?
Thanks!
So I have two choices:
I'm assuming both variants have advantages and disadvantages, right?
Think "A" is good, if i use the object often in different places. I think B is good when i rarely need the object. Does deinit frees up resources?
So I have two choices:
- A.) I create *one* instance and use it everywhere.
- B.) I have to use deinit() when I don't need the ADC at the moment.
I'm assuming both variants have advantages and disadvantages, right?
Think "A" is good, if i use the object often in different places. I think B is good when i rarely need the object. Does deinit frees up resources?