upm/examples/c/gp2y0a.c
Jon Trulson e7c80217c2 C examples: move mraa_init() calls out of C examples and into C drivers.
Signed-off-by: Jon Trulson <jtrulson@ics.com>
2016-09-28 17:34:42 -06:00

28 lines
547 B
C

//Modified: Abhishek Malik <abhishek.malik@intel.com>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include "gp2y0a.h"
#include "upm_utilities.h"
int main()
{
gp2y0a_context dev = gp2y0a_init(14, 5.0);
float val;
while(1){
if(gp2y0a_get_value(dev, 5.0, 20, &val) != UPM_SUCCESS){
printf("Failed to get any values from the sensor\n");
}
printf("Moisture Value: %f\n", val);
upm_delay(1);
}
gp2y0a_close(dev);
return 0;
}