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

Files at this revision

API Documentation at this revision

Comitter:
switches
Date:
Wed May 04 16:39:08 2016 +0000
Parent:
8:fb192510004d
Child:
10:102944c2d59c
Commit message:
MAX44000 Demo. draft for release

Changed in this revision

ALS_ARD2PMOD_Demo.lib Show annotated file Show diff for this revision Revisions of this file
MAX44000.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ALS_ARD2PMOD_Demo.lib	Wed May 04 16:39:08 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/Maxim-Integrated/code/ALS_ARD2PMOD_Demo/#fb192510004d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MAX44000.lib	Wed May 04 16:39:08 2016 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/MaximIntegrated/code/MAX44000/#1a770989adcb
--- a/main.cpp	Fri Apr 08 22:21:11 2016 +0000
+++ b/main.cpp	Wed May 04 16:39:08 2016 +0000
@@ -12,12 +12,6 @@
  *
  * The following boards have been tested to work:
  *   MAX32600MBED
- *   FRDM-KL25Z 
- *   FRDM-K64F
- *   Seeeduino Arch (LEDs inverted)
- *   Seeeduino Arch Pro
- *   ST Nucleo L152RE/F401RE (B row only, single LED, inverted)
- *   LPCXpresso1549
  *  
  * 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.  
@@ -25,8 +19,9 @@
 
 #include "mbed.h"
 #include "ard2pmod.h"
+#include "MAX44000.h"
 
-I2C i2c(D14, D15);
+MAX44000 max44000(D14, D15);
 DigitalOut tog(LED1);
 DigitalOut als(LED2);
 DigitalOut dly(LED3);
@@ -35,26 +30,13 @@
 DigitalIn pa3(D12);  // Set as input to remove load from PA3
 DigitalIn pa4(D13);  // Set as input to remove load from PA4
 
-const int alsAddr = 0x94;
 const int alsLim = 0x0008;
 
 int main()
 {
-    Ard2Pmod ard2pmod(Ard2Pmod::PMOD_TYPE_I2C_B);  // Configure ard2pmod multiplexer for I2C
-    char cmd[2];
-    int alsData;
-
-    cmd[0] = 0x02;  // Receive Register
-    cmd[1] = 0xFC;  // 1.56ms, 1x
-    i2c.write(alsAddr, cmd, 2);
+    Ard2Pmod ard2pmod(Ard2Pmod::PMOD_TYPE_I2C_B);  // Configure ard2pmod multiplexer for I2C row B (bottom row)
 
-    cmd[0] = 0x03;  // Transmit Register
-    cmd[1] = 0x0F;  // 110mA
-    i2c.write(alsAddr, cmd, 2);
-    
-    cmd[0] = 0x01;  // Config Register
-    cmd[1] = 0x10;  // ALS/Prox Mode
-    i2c.write(alsAddr, cmd, 2);
+    max44000.init(MAX44000::MODE_ALS_PROX, MAX44000::ALSTIM_64X, MAX44000::ALSPGA_1X, MAX44000::DRV_110);
 
     bool lastProx = false;
     int offDelay = 0;
@@ -64,16 +46,12 @@
 
     while (true) {
         wait (0.02);
-        cmd[0] = 0x05; // ALS Data Register Low
-        i2c.write(alsAddr, cmd, 1, true);
-        i2c.read(alsAddr, cmd, 1);
-        alsData = cmd[0];
+        int alsData = max44000.readALS();
+        int proxData = max44000.readReg(MAX44000::REG_PRX_DATA);
+
         als = (alsData < alsLim);
 
-        cmd[0] = 0x16; // Prox Data Register
-        i2c.write(alsAddr, cmd, 1, true);
-        i2c.read(alsAddr, cmd, 1);
-        if (cmd[0]) {
+        if (proxData) {
             if (!lastProx) {
                 tog = !tog;
             }