// Name : AINRead.cpp
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include <stdio.h>
#include <unistd.h>
using namespace std;
//uncomment which file path you wish to use
// gives value in terminal from 0 - 4055
//char *Remote = "/sys/bus/iio/devices/iio:device0#/in_voltage5_raw";
//gives value in terminal from 0 - 1499
//char *Remote = "/sys/devices/ocp.2/helper.17/AIN5";
FILE * raw_volt;
int iteration = 0;
int main() {
//how its read in terminal
//cat /sys/bus/iio/devices/iio:device0#/in_voltage5_raw // gives value 0-4055
//cat /sys/devices/ocp.2/helper.17/AIN5 //gives value 0-1499
while(iteration < 1000) // how many times the loop runs
{
raw_volt = fopen(Remote, "r+"); // reads analog input and stores in variable raw_volt
// on the off chance that the value stored in raw_volt is already string
printf("raw_volt \n", raw_volt);
char c[10]; //this segment should convert raw_volt to string
sprintf(c,"%d",raw_volt);
printf ("voltage in : %s \n", c);
usleep(1000);
iteration += 1;
}
}
any help in deciphering what im doing wrong would be a big help also let me know if ive left any pertinent information out