I'm busy using an arduino uno to make a "Blind" solar tracker for on top of a RC car. Currently, I am using all 6 ADC pins as I am managing the charging of a Li-ion battery (So I'm measuring voltage of the battery as well as the current being delivered to the battery) and the other 3 pins are being used by an accelereometer which measures the tilt of my solar panel. I am using a gps to find longitude, latitude, date and time (They use digital pins).
So now I have come short as I need ADC pins for my magnetometer to find due north. Is there anyway to convert a digital pin to an analogue in pin for ADC use?
Thanks in advance
Edit- I am aware I can find the direction using the GPS once the RC car starts moving by taking two co-ordinates readings and doing some maths, but if the car is still is there any way?
Is it an option to use a Nano (8 analog inputs)? Or a Mega (16 analog inputs)? Alternatively you can use an analog multiplexer (e.g. 74HC4051 or 74HC4067).
You can only use the analog pins for analog measurements; no way of converting a digital pin to analog.
MattyZeee:
Unfortunately I have to use the UNO, but I will definitely look into the multiplexers. Thank you!
Very unfortunate indeed, as the Nano is a vastly more practical form factor with exactly the same functionality as the UNO* (and two extra ADC inputs).
Adding the multiplexer would be at least as difficult as swapping to a Nano, both mechanically and in code - and for similar overall cost.
(*) Unless you need extra functionality from the 16U2, which is most improbable indeed - you likely do not even know about it.
Why not get a combined or separate accelerometer and magnetometer modules with i2c interface? Then you will need 5 fewer ADC pins. But also you need to free up A4 and A5 to use i2c interface.