//----------------------------------------------------------------------------- // Sprache : C // Version : 1.0 // Autor : Christian Müller - www.myAVR.de // Prozessor : ATmega2560 // Takt : 16 MHz // Programmer : mySmartUSB MK3 //----------------------------------------------------------------------------- // Titel : 7-Segment-Anzeige // Sample W02 - myAVR Beispiel für MK3 Board // (mehr und ausfühlicher im SiSy-Projekt im Download unter www.myAVR.de) // title : 7-Segment-display // Sample W02 - myAVR Sample for the MK3 board // (more details in the SiSy-project at download on www.myAVR.de) //----------------------------------------------------------------------------- // Funktion : Zeigt die einzelnen Zeichen einen selbst erstellten Zeichensatz auf der 7-Segment-Anzeige aus. // function : Shows the single characters of a selfmade Font on the 7-segment-display. // Schaltung : Quick-Connect "7Seg on Port-B" auf dem MK3 Board // circuit : Quick-Connect "7Seg on Port-B" at the MK3 Board //----------------------------------------------------------------------------- #define F_CPU 16000000 #include //----------------------------------------------------------------------------- //de: der Zeichensatz, ein Feld das die Bitkombinationen der einzelnen Zeichen enthält //eng: the font, a array that contains the bitcombination of the single characters uint8_t font7seg [] = { 0b00111111, /* 0 */ 0b00000110, /* 1 */ 0b01011011, /* 2 */ 0b01001111, /* 3 */ 0b01100110, /* 4 */ 0b01101101, /* 5 */ 0b01111101, /* 6 */ 0b00000111, /* 7 */ 0b01111111, /* 8 */ 0b01101111, /* 9 */ 0b01110111, /* A */ 0b01111100, /* B */ 0b00111001, /* C */ 0b01011110, /* D */ 0b01111001, /* E */ 0b01110001, /* F */ 0b01000000, /* - */ 0b00000000, /* */ 0b01001001 /* 3 waagerechte */ }; //----------------------------------------------------------------------------- //de: Hauptfunktion //eng: mainfunction int main (void) { // Init //de: Port-B als Ausgang konfigurieren (für 7-Segment-Anzeige) //eng: config port-B as output, (for the 7-segment-display) DDRB=0xFF; //de: der Zähler, mit Null vorbelegen //eng: the counter, init with zero uint8_t index=0; // Mainloop while (true) { //de: das Zeichen welches an Position von index im Zeichensatz steht an Port-B ausgeben //eng: output the character, at position of index in the font, on port-B PORTB=font7seg[index]; //de: den Zähler um eins hochzählen //eng: increase the counter by one index++; //de: wenn Zähler grösser als Anzahl der Zeichen im Zeichensatz, dann Zähler wieder auf erstes Zeichen setzen //eng: if the counter is higher as the count of characters in the font, set counter to the first charcater if(index==19) index=0; //de: 500ms warten = Makro aus der myAVR.h (Include über io.h) //eng: wait 500ms = macro in the myAVR.h (included by io.h) waitMs(500); } return 0; } //-----------------------------------------------------------------------------