Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 1 month ago.
Using KL25Z and a RGB sensor to test External LEDs
Hi
I am in need of code that will allow my RGB sensor to work with ports on my KL25Z board that will read the light intensity and give feedback. I currently have external LED arrays connected to PWM ports on the board. I am running code that is changing the intensities of the LEDS to simulate a certain environment, but need feedback.
1 Answer
10 years, 1 month ago.
Can you tell us what RGB sensor you are using? We can't help much without this information.
First and foremost thank you for the reply. Here is a link to the sensors I am trying to implement into my system https://www.sparkfun.com/products/12829. It is the ISL29125 RGB Light Sensor
posted by 19 Nov 2014You're in luck. I already created a library and sample code for this sensor - have a look at https://developer.mbed.org/components/ISL29125/.
posted by 19 Nov 2014I am still having trouble determining where the data is writing to when running in ISR mode?
posted by 03 Dec 2014When you look at the demo code at https://developer.mbed.org/users/frankvnk/code/ISL29125_demo/file/098ae9ac1461/main.cpp, an interrupt only occurs when a user defined threshold level is reached (in the demo code, RGBsensor_irq is called). If you only want to read the sensor data when an interrupt occurs, add RGBsensor.Read(ISL29125_RGB, GRBdata); to RGBsensor_irq.
IMPORTANT : Carefully read the comment at the end of the demo code as it contains important info about how fast we can read the sensor data when interrupts are enabled. This is a limitation that i could not solve - i even asked for support from Intersil but i didn't get any reply. So make sure there is a delay between consecutive reads. I know this somewhat breaks the possibility to read the data when an interrupt occurs. That's also the reason why my demo code is setup this way : set a marker when an interrupt occurs and process/clear this marker when ALSread() is called (every 200ms, the irq marker is checked and the sensor data is copied to the global variable GRBdata). Obviously, this means we can easily miss interrupts when they occur more than once within 200ms.
When you look at the Sparkfun interrupt demo code, they also add a delay (100ms) between consecutive reads and only increment a counter when an interrupt occurs. This counter is monitored in the main loop. As a result, we exactly know how many interrupts occured during the 100ms but we don't know the values that triggered the interrupts - we only know the user defined threshold was reached multiple times.
posted by 03 Dec 2014