Demonstrates the MAX44000 library and some of the features of the MAX44000

Dependencies:   MAX44000 ard2pmod mbed

Fork of ALS_ARD2PMOD_Demo by Maxim Integrated

MAX44000PMB1 Demonstration

This demonstrates some of the capabilities of the MAX44000. This is written to work with the MAXREFDES72# adapter board and the MAX44000PMB1 peripheral module. It uses the standard Arduino pin names and it will compile for most arduino form-factor mbed boards. /media/uploads/switches/max44000pmb1_demo.jpg To run this demonstration you will need:

In this demonstration the LEDs are changed based on data from the sensor.

  • LED1 toggles when something is first detected by the proximity sensor.
  • LED2 indicates when the Ambient Light Sensor reads greater than a set value (alsLim).
  • LED3 will stay on whenever something is detected by the proximity sensor and stay on for an additional 5s after it is no longer detected.

Note: Some boards use D13 for an LED signal, so this example uses the second row (row B, pins 7 through 12) of the Pmod connector. /media/uploads/switches/max44000_align.jpg

Tested platform boards

Links to external supporting material

Revision:
4:226ef11c3ef4
Parent:
3:61cc32322303
Child:
5:b39bfe8e3d09
--- a/main.cpp	Mon Jun 23 05:30:26 2014 +0000
+++ b/main.cpp	Mon Jun 30 22:32:02 2014 +0000
@@ -33,18 +33,19 @@
 DigitalIn pb4(D7);  // Set as input to remove load from PB4
 
 const int alsAddr = 0x94;
-const char alsLim = 0x01;
+const int alsLim = 0x0008;
 
 int main()
 {
     char cmd[2];
+    int alsData;
 
     //  SDA (D14) + PB4 (D7)     SCL (D15) + PB3 (D6)
     mux.setAB((MAX14661::SW10 | MAX14661::SW08),
               (MAX14661::SW09 | MAX14661::SW07));
 
     cmd[0] = 0x02;  // Receive Register
-    cmd[1] = 0xFF;  // 1.56ms, 128x
+    cmd[1] = 0xFC;  // 1.56ms, 1x
     i2c.write(alsAddr, cmd, 2);
 
     cmd[0] = 0x03;  // Transmit Register
@@ -63,13 +64,14 @@
 
     while (true) {
         wait (0.02);
-        cmd[0] = 0x04; // ALS Data Register
-        i2c.write(alsAddr, cmd, 1);
+        cmd[0] = 0x05; // ALS Data Register Low
+        i2c.write(alsAddr, cmd, 1, true);
         i2c.read(alsAddr, cmd, 1);
-        als = (cmd[0] < alsLim);
+        alsData = cmd[0];
+        als = (alsData < alsLim);
 
         cmd[0] = 0x16; // Prox Data Register
-        i2c.write(alsAddr, cmd, 1);
+        i2c.write(alsAddr, cmd, 1, true);
         i2c.read(alsAddr, cmd, 1);
         if (cmd[0]) {
             if (!lastProx) {