I'm trying to use SparkFun's ISL29125 RBG sensor for a line following project. I can't figure how to take the sensor reading and apply it in an if statement. The ISL29125_basics.ino works fine to print out the color values which are what would be used in the if statement. I just don't know how to get that value into the if statement. Any help would be appreciated.
/******************************************************************************
ISL29125_basics.ino
Simple example for using the ISL29125 RGB sensor library.
Jordan McConnell @ SparkFun Electronics
11 Apr 2014
https://github.com/sparkfun/SparkFun_ISL29125_Breakout_Arduino_Library
This example declares an SFE_ISL29125 object called RGB_sensor. The
object/sensor is initialized with a basic configuration so that it continuously
samples the light intensity of red, green and blue spectrums. These values are
read from the sensor every 2 seconds and printed to the Serial monitor.
Developed/Tested with:
Arduino Uno
Arduino IDE 1.0.5
Requires:
SparkFun_ISL29125_Arduino_Library
This code is beerware.
Distributed as-is; no warranty is given.
******************************************************************************/
#include <Wire.h>
#include "SparkFunISL29125.h"
// Declare sensor object
SFE_ISL29125 RGB_sensor;
void setup()
{
// Initialize serial communication
Serial.begin(115200);
// Initialize the ISL29125 with simple configuration so it starts sampling
if (RGB_sensor.init())
{
Serial.println("Sensor Initialization Successful\n\r");
}
}
// Read sensor values for each color and print them to serial monitor
void loop()
{
// Read sensor values (16 bit integers)
unsigned int red = RGB_sensor.readRed();
unsigned int green = RGB_sensor.readGreen();
unsigned int blue = RGB_sensor.readBlue();
// Print out readings, change HEX to DEC if you prefer decimal output
Serial.print("Red: "); Serial.println(red,DEC);
// Serial.print("Green: "); Serial.println(green,HEX);
// Serial.print("Blue: "); Serial.println(blue,HEX);
// Serial.println();
// delay(100);
}