Hi I was wondering if there is any way to/ how I might go about solving the following.
I am designing my own arduino board based on a mega32u4 chip and I want my arduino board to light up an indicator led depending on if an analog pin is in use. For example if a user uploads code that utilizes a certain pin say reading a voltage from A0, the arduino would light up an LED next to that pin.
I was thinking perhaps I could tie the analog pin to a digital pin in the firmware and have the digital pin go HIGH every time the analog pin is in use(is this possible/ could anyone point me to good examples online)?
The user needs to know whether or not the pin they think is writing is actually outputting a signal and/or if the pin they think is reading is reading a signal. This is beacause they will be hooking up outputs and inputs to the arduino board using conductive ink and if their circuit isnt working the indicator lights will let them know that their software is working but there is probably a break in the circuitry they drew out.
2 Answers 2
When you upload code that is the firmware. There isn't another lot of firmware (like an operating system) that is always there (excepting the bootloader which is only used for uploading new code).
Maybe you could connect an LED, via an op-amp as an amplifier, to the analog pin, so that if a voltage appears that it would light the LED. However it could be "in use" and reading zero volts so that wouldn't prove an enormous lot.
would it be ill advised to attempt a solution on the lines of what Mikael proposed in the comments?
You can make your own analogRead function and encourage your users to use it (or do it via a #define) however that will only work if people use your new function or header file.
It would also have the side-effect of making other pins not available (ie. the pins you are doing the LED on) which might be confusing for users who are trying to use all available pins.
I assume this is some sort of teaching gadget? It might be better to teach people to do an indicator LED themselves rather than trying to automate it for them.
-
Thanks for the clarification Nick, would it be ill advised to attempt a solution on the lines of what Mikael proposed in the comments?Chris– Chris2018年08月31日 14:58:54 +00:00Commented Aug 31, 2018 at 14:58
-
See amended answer.2018年09月02日 21:46:17 +00:00Commented Sep 2, 2018 at 21:46
Create a library. User will include it and the h file will create a single instance of the handler object for your pin pairs. The handler will register a timer interrupt, and the interrupt will check the source pin and set the target pin.
analogRead()
, or just that something is connected to the pin?