- Edited
I want to use analog inputs for my potentiometers to control audio speed and volume, but I don't want to use the ADC on the Bela Mini as its expensive if I want to make multiple of these boards.
Currently I am using the following script as an AuxiliaryTask:
#define LDR_PATH "/sys/bus/iio/devices/iio:device0/in_voltage5_raw"
int number;
void readAdc(void *){
stringstream ss;
ss << LDR_PATH;
fstream fs;
fs.open(ss.str().c_str(), fstream::in);
fs >> number;
fs.close();
}
This worked well, except sometimes it drops readings and defaults to 0. I also tried putting this code in the loop when the audio is being played back, but that cause my CPU to spike.
Are there any examples on how to access the Pocket Beagle ADC pins so I can utilize them?
Thanks!