Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of _B15Test5 by
Revision 0:a8a0195ed7dc, committed 2015-01-26
- Comitter:
- Enenkel
- Date:
- Mon Jan 26 21:46:32 2015 +0000
- Child:
- 1:628da1b465a4
- Commit message:
- I2C Einlesen der Tasten und Ausgabe auf die LED
Changed in this revision
| 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 |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Mon Jan 26 21:46:32 2015 +0000
@@ -0,0 +1,44 @@
+/***********************************
+name: BERTL14_I2C_TEST
+author: Enenkel modifizert von Wolfgang Raimann
+description:
+ Die Taster vom I2C Expander werden direkt auf die LED's des Expander geschalten
+***********************************/
+
+#include "mbed.h"
+I2C i2c(p28, p27); // die Adressen des I2C Busses am uP
+ // p28 -> SDA
+ // p27 -> SCL
+int main() {
+ char btn = 0;
+ // **** Config PCA9555 I0 as output *******
+ i2c.start();
+ i2c.write(0x40); // Adresse des PCA9555 = 40
+ // das letzte Bit = 0 -> schreiben 0040 0000
+ i2c.write(0x06); // Befehl für das IO Port 0 -> siehe SCHEMA des PCA9555
+ i2c.write(0x00); // Schalte alle Pins des Ports als OUTPUT
+ i2c.stop();
+
+ while(1) {
+ // Einlesen der Taster und speichern unter btn
+ i2c.start();
+ /* Das letzte Bit der Adresse entscheidet
+ ob geschrieben oder gelesen wird.
+ 0 => schreiben; 1 => lesen */
+ i2c.write(0x40); //Adresse & schreiben 0100 0000
+ i2c.write(0x01); //aktivate Port 1
+
+ i2c.start();
+ i2c.write(0x41); // Adresse & LESEN 0100 0001
+ btn = i2c.read(0);// Einlesen des Ports 1 und speichern unter btn
+ i2c.stop();
+
+ // Schreiben auf Port 0 und damit auf die LED's
+ i2c.start();
+ i2c.write(0x40); // Adresse & schreiben
+ i2c.write(0x02); //
+ i2c.write(~btn); // schriebn auf Port 0 den INVERSEN Wert von btn
+ i2c.stop();
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Jan 26 21:46:32 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5 \ No newline at end of file
