I'm having difficulty using the analog input for the CrazyFlie 2.0. I have a small circuit built which is testing the output of a pin (HELLO_LED) based on the voltage input of another pin (READ_LED). I have tested with various voltages, but the output LED never seems to trigger. Does anyone have some working code for readAnalogVoltage, or can you spot what's wrong with my code? Thank you!
The problem may be if there is an additional driver I have not started, or something missing from the build configuration?
The deck code is loading, I can see its output on the console. I modified this deck to use digital input on the same pins and in that case it works - the LED on HELLO_LED will light when I pass the right voltage into the READ_LED pin.
That is an unexpected behavior. In the analogRead function the pin is setup in analog mode before analog conversion so shouldn't be necessary to put it in digital input...
Right, I saw that. I'm not setting it to digital mode in my analog tests. But as a sanity check (to test if the pin had a short or something?) I tried it in digital mode instead and it worked - so I know the pin is physically ok. So I set the code back to using analog and it gets nothing useful, usually what seems to be a floating value around 0.1V that changes every time I restart the drone.
Does anyone have sample code for a basic deck doing analog input?