Hello world for Rohm BH1726 ALS dual channel sensor. Uses Rohm sensor hal and bh1726 driver.
Dependencies: mbed rohm-bh1726 rohm-sensor-hal
Fork of rohm-bh1745-hello by
Revision 4:a9efa968de28, committed 2016-09-12
- Comitter:
- MikkoZ
- Date:
- Mon Sep 12 12:34:04 2016 +0000
- Parent:
- 3:e22f64655c63
- Child:
- 5:a8feb1b6e6b5
- Commit message:
- Initial version of bh1745 hello world. Outputs sensor data with default setup.
Changed in this revision
--- a/main_classic.cpp Mon Sep 12 09:55:47 2016 +0000
+++ b/main_classic.cpp Mon Sep 12 12:34:04 2016 +0000
@@ -16,37 +16,37 @@
#include "rohm-sensor-hal/rohm-sensor-hal/rohm_hal.h" //mbed.h, types, DEBUG_print*
#include "rohm-sensor-hal/rohm-sensor-hal/I2CCommon.h"
-#include "rohm-rpr0521/rohm-rpr0521/rpr0521_driver.h"
-#include "rohm-rpr0521/rohm-rpr0521/rpr0521.h"
+#include "rohm-bh1745/rohm-bh1745/bh1745_driver.h"
+#include "rohm-bh1745/rohm-bh1745/bh1745.h"
Serial pc(USBTX, USBRX);
-void rpr0521_print_raw_values(){
- pc.printf("\nRPR0521 library test program.\n\r");
+void bh1745_print_raw_values(){
+ pc.printf("\nbh1745 library test program.\n\r");
I2CCommonBegin();
- rpr0521_wait_until_found();
+ bh1745_wait_until_found();
pc.printf("\nSensor found.\n\r");
- rpr0521_initial_setup();
+ bh1745_initial_setup();
wait(1);
while(1) {
bool error;
- uint16_t data[3];
+ uint16_t data[4]; //4 channels of 16-bit data
- error = rpr0521_read_data(&data[0]);
+ error = bh1745_read_data(&data[0]);
if (!error) {
- pc.printf("PS[%4u], Als0[%4u], Als1[%4u]\n\r", data[0], data[1], data[2]);
+ pc.printf("Red[%4u], Green[%4u], Blue[%4u], Clear[%4u]\n\r", data[0], data[1], data[2], data[3]);
}
else {
pc.printf("\n\r");
}
- wait(0.1);
+ wait(0.2);
}
}
int main() {
- rpr0521_print_raw_values();
+ bh1745_print_raw_values();
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rohm-bh1745.lib Mon Sep 12 12:34:04 2016 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/Rohm/code/rohm-bh1745/#64629eee9eab
--- a/rohm-rpr0521.lib Mon Sep 12 09:55:47 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://developer.mbed.org/teams/Rohm/code/rohm-rpr0521/#0bcc203c5c75

Rohm BH1726NUC | Ambient Light Sensor