From a1abab8909a465d392dfa3272c284da694fec58e Mon Sep 17 00:00:00 2001 From: Sarah Knepper Date: Thu, 4 Dec 2014 10:40:39 +0000 Subject: [PATCH] grovelight.cxx: improve example code Signed-off-by: Sarah Knepper Signed-off-by: Brendan Le Foll --- examples/grovelight.cxx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/examples/grovelight.cxx b/examples/grovelight.cxx index 17f769be..64760c97 100644 --- a/examples/grovelight.cxx +++ b/examples/grovelight.cxx @@ -1,5 +1,6 @@ /* * Author: Brendan Le Foll + * Contributions: Sarah Knepper * Copyright (c) 2014 Intel Corporation. * * Permission is hereby granted, free of charge, to any person obtaining @@ -29,11 +30,19 @@ int main(int argc, char **argv) { - // This example uses AIO 0 //! [Interesting] + // Create the light sensor object using AIO pin 0 upm::GroveLight* light = new upm::GroveLight(0); - int lightValue = light->value(); + // Read the input and print both the raw value and a rough lux value, + // waiting one second between readings + while( 1 ) { + std::cout << light->name() << " raw value is " << light->raw_value() << + ", which is roughly " << light->value() << " lux" << std::endl; + sleep(1); + } + + // Delete the light sensor object delete light; //! [Interesting] return 0;