PCF8574 I2C to GPIO interface IC to 4x4 matrix keypad and access the 16 keys for different purposes

Dependencies:   PCF8574 mbed

Files at this revision

API Documentation at this revision

Comitter:
aslam
Date:
Wed May 20 10:34:30 2015 +0000
Commit message:
PCF8574 interface IC (I2C to GPIO) to 4x4 matrix keypad

Changed in this revision

PCF8574.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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r a12361c5f212 PCF8574.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PCF8574.lib	Wed May 20 10:34:30 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/PCF8574/#ec8da0c59403
diff -r 000000000000 -r a12361c5f212 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed May 20 10:34:30 2015 +0000
@@ -0,0 +1,57 @@
+#include "mbed.h"
+#include "PCF8574.h"
+
+#define BAUD 9600
+InterruptIn event(p12);
+Serial pc(USBTX, USBRX); 
+PCF8574 io(p9,p10,0x40);
+int data1 , data2;
+
+void display(int data)
+{
+switch (data)
+{
+    case 238: pc.printf("SW1 \n\r"); break;
+    case 237: pc.printf("SW2 \n\r"); break;
+    case 235: pc.printf("SW3 \n\r"); break;
+    case 231: pc.printf("SW4 \n\r"); break;
+    case 222: pc.printf("SW5 \n\r"); break;
+    case 221: pc.printf("SW6 \n\r"); break;
+    case 219: pc.printf("SW7 \n\r"); break;
+    case 215: pc.printf("SW8 \n\r"); break;
+    case 190: pc.printf("SW9 \n\r"); break;
+    case 189: pc.printf("SW10 \n\r"); break;
+    case 187: pc.printf("SW11 \n\r"); break;
+    case 183: pc.printf("SW12 \n\r"); break;
+    case 126: pc.printf("SW13 \n\r"); break;
+    case 125: pc.printf("SW14 \n\r"); break;
+    case 123: pc.printf("SW15 \n\r"); break;
+    case 119: pc.printf("SW16 \n\r"); break;
+    }    
+}
+
+        void trigger() 
+            {
+                //event.fall(NULL);
+               //printf("triggered!\n");
+                io.write(0x0f);
+                data1 = io.read();
+            
+                io.write(0xf0);
+                data2 = io.read();
+                
+                display(data1+data2);
+                //wait(0.2);
+                //event.fall(&trigger);
+            }
+
+int main()
+{    
+    pc.printf("Start\n\r");
+    event.fall(&trigger);
+    //event.rise(&trigger);
+    while(1) 
+    {
+    
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r a12361c5f212 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed May 20 10:34:30 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/029aa53d7323