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
main.cpp
00001 /*********************************** 00002 name: BERTL_2014_LAMPENTEST 00003 modyfied by ENE@bulme.at 00004 description: 00005 Alle LED sind INVERS dh 0 = EIN; 1 = AUS; 00006 ***************************************/ 00007 #include "mbed.h" // Softwarestand: 19.1.2014 00008 /*** Portkonfiguration ***/ 00009 Serial pc(USBTX, USBRX); // tx, rx 00010 I2C i2c(p28,p27); 00011 00012 /*** Funktionsdefinitionen ***/ 00013 const int addr = 0x40; // I2C-Adresse des PCA9555 00014 char cmd[3]; // Datenarray für I2C 00015 00016 /*** Funktionen ***/ 00017 int main() 00018 { 00019 /*** I2C Konfigurationen ***/ 00020 i2c.frequency(40000); // I2C Frequenz 40kHz 00021 cmd[0] = 0x06; // Comman6 6 Portkonfiguration Port 0 00022 cmd[1] = 0x00; // 00-> Port 0 = OUTPUT (all Pins 00) 00023 i2c.write(addr, cmd, 2); // Sende Adresse 0x40; cmd, s -> 0x06 0x00 00024 // Defines Port0 as Output 00025 cmd[0] = 0x02; // OUTPUT Port 0 00026 00027 /*** Hauptprogramm - Endlosschleife ***/ 00028 while(1) 00029 { 00030 // 0x00 00031 cmd[1] = 0x00; // Alle LED EIN 0000 0000 00032 i2c.write(addr, cmd, 2); 00033 wait(2); 00034 // 0xF F 00035 cmd[1] = 0x00; // Alle LED AUS 1111 1111 00036 i2c.write(addr, cmd, 2); 00037 wait(0.5); 00038 // F E 00039 cmd[1] = 0xFE; // D1 vorn links ws 1111 1110 00040 i2c.write(addr, cmd, 2); 00041 wait(0.5); 00042 // F D 00043 cmd[1] = 0xFD; // D2 vorn links ge 1111 1101 00044 i2c.write(addr, cmd, 2); 00045 wait(0.5); 00046 // F B 00047 cmd[1] = 0xFB; // D4 vorn rechts ws 1111 1011 00048 i2c.write(addr, cmd, 2); 00049 wait(0.5); 00050 00051 cmd[1] = 0xF7; // sieh ab hier in den Schaltplan 00052 i2c.write(addr, cmd, 2); 00053 wait(0.5); 00054 00055 cmd[1] = 0xEF; // 00056 i2c.write(addr, cmd, 2); 00057 wait(0.5); 00058 00059 cmd[1] = 0xDF; // 00060 i2c.write(addr, cmd, 2); 00061 wait(0.5); 00062 00063 cmd[1] = 0xBF; 00064 i2c.write(addr, cmd, 2); 00065 wait(0.5); 00066 00067 cmd[1] = 0x7F; 00068 i2c.write(addr, cmd, 2); 00069 wait(0.5); 00070 // F F 00071 cmd[1] = 0xFF; // Alle LED AUS 1111 1111 00072 i2c.write(addr, cmd, 2); 00073 wait(1); 00074 } 00075 }
Generated on Thu Jul 14 2022 18:13:01 by
1.7.2