Bertl 2014 Übung
Dependencies: mbed
Fork of _B14Test8 by
Diff: main.cpp
- Revision:
- 0:951a35674581
- Child:
- 1:d1a664b263dc
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Nov 18 14:17:57 2014 +0000 @@ -0,0 +1,76 @@ +#include "mbed.h" // Softwarestand: 19.1.2014 +/*** Portkonfiguration ***/ +Serial pc(USBTX, USBRX); // tx, rx +I2C i2c(p28,p27); + +/*** Funktionsdefinitionen ***/ +Ticker sekunden; +Ticker blink; + +/*** Variablendefinitionen ***/ +// int x = 1 ; +// int y = 0 ; +// bool var1 = false; + +const int addr = 0x40; // I2C-Adresse PCA9555 +char cmd[3]; // Datenarray für I2C + +/*** Funktionen ***/ + +int main() +{ +/*** I2C Konfigurationen ***/ + i2c.frequency(40000); // I2C Frequenz 40kHz + + cmd[0] = 0x06; + cmd[1] = 0x00; + i2c.write(addr, cmd, 2); // Define Port0 = Out +/*** Hauptprogramm - Endlosschleife ***/ + while(1) + { + cmd[0] = 0x02; + cmd[1] = 0xFE; // Alle LED ON + i2c.write(addr, cmd, 2); // Def. Port0 = 0x00 + wait(0.5); + + cmd[0] = 0x02; // + cmd[1] = 0xFD; // Alle LED OFF + i2c.write(addr, cmd, 2); // Def. Port0 = 0xFF + wait(0.5); + + cmd[0] = 0x02; // + cmd[1] = 0xFB; // Alle LED OFF + i2c.write(addr, cmd, 2); // Def. Port0 = 0xFF + wait(0.5); + + cmd[0] = 0x02; // + cmd[1] = 0xF7; // Alle LED OFF + i2c.write(addr, cmd, 2); // Def. Port0 = 0xFF + wait(0.5); + + cmd[0] = 0x02; // + cmd[1] = 0xEF; // Alle LED OFF + i2c.write(addr, cmd, 2); // Def. Port0 = 0xFF + wait(0.5); + + cmd[0] = 0x02; // + cmd[1] = 0xDF; // Alle LED OFF + i2c.write(addr, cmd, 2); // Def. Port0 = 0xFF + wait(0.5); + + cmd[0] = 0x02; // + cmd[1] = 0xBF; // Alle LED OFF + i2c.write(addr, cmd, 2); // Def. Port0 = 0xFF + wait(0.5); + + cmd[0] = 0x02; // + cmd[1] = 0x7F; // Alle LED OFF + i2c.write(addr, cmd, 2); // Def. Port0 = 0xFF + wait(0.5); + + cmd[0] = 0x02; // + cmd[1] = 0x00; // Alle LED OFF + i2c.write(addr, cmd, 2); // Def. Port0 = 0xFF + wait(2); + } +}