-extracredit

Dependencies:   mbed

Revision:
0:574e155464d5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Jan 28 04:08:50 2015 +0000
@@ -0,0 +1,29 @@
+#include "mbed.h"
+#include "MCP23S17.h"
+
+//------------------------------//
+SPI spi(p5, p6, p7);
+char Opcode1 = 0x40;
+char Opcode2 = 0x42;
+MCP23S17 chip1 = MCP23S17(spi, p20, Opcode1);
+MCP23S17 chip2 = MCP23S17(spi, p20, Opcode2);
+//-------------------------------//
+
+int main()
+{
+
+    chip1.direction(PORT_A, 0x00); //output
+    chip2.direction(PORT_B, 0xFF); //input
+
+    while (1) {
+
+        if(chip2.read(PORT_B)) {
+            chip1.write(PORT_A, 0x00);
+        } else {
+            chip1.write(PORT_A, 0xAA);
+        }
+
+
+    }
+
+}
\ No newline at end of file