// gps_tacho_uhr_7-segment-led_sapoa // Die KMH Anzeige wird nach 2 Sekunden im Tunnel ohne Empfang ausgeschaltet // Arduino Nano vom 14.05.2023 // Nicht D2, soll freibleiben // Nicht D5, soll freibleiben // Demonstrates use of the Wire library // Writes data to an I2C/TWI slave device slave = (8) // Refer to the "Wire Slave Receiver" example for use with this // PIN A4 = gelbes Kabel => für i2c Wire.h mit Pull-Up Widerstand 4.700 Ohm zu 5V // PIN A5 = grünes Kabel => für i2c Wire.h mit Pull-Up Widerstand 4.700 Ohm zu 5V //******************************************************* // Anschlüsse 7Segment mit Max7219 // VCC - rotes Kabel - rotes Kabel - Arduino 5V // GND - schwarzes Kabel - schwarzes Kabel - Arduino GND // DIN - weißes Kabel - weißes Kabel - Arduino D12 // CS - gelbes Kabel - braunes Kabel - Arduino D10 ( gelb bei neuen 7Segment ) // CLK - blaues Kabel - blaues Kabel - Arduino D11 //******************************************************* // Anschlüsse GPS6MV2 Modul // VCC - rotes Kabel - gelbes Kabel - Arduino 3,3V // RX - schwarzes Kabel - graues Kabel - Arduino D3 // TX - weißes Kabel - grünes Kabel - Arduino D4 // GND - gelbes Kabel - schwarzes Kabel - Arduino GND //******************************************************* // Schalter für Sommerzeit // weißes Kabel - Arduino D9 // schwarzes Kabel - Arduino GND //******************************************************* #include #include #include "LedControl.h" #include unsigned long kmphalter = 0; // Alter der Daten kmph in Millisekunden int vers = 5; int minutens = 0; // rohe Minuten int hourasr = 0; // rohe Stunden eins int houras = 0; // rohe Stunden zwei int kmhgpsr = 0; // rohe Kilometer pro Stunde int kmhgps = 0; // geglättete Kilometer pro Stunde int kmhwire = 0; // Kilometer pro Stunde zum Senden über Wire char c7 = '3'; // Das Zeichen an der Hunderter-Stelle char c6 = 'A'; // Das Zeichen an der Zehner-Stelle char c5 = '3'; // Das Zeichen an der Einer-Stelle int z7 = 0 ; // Die Ziffer an der Hunderter-Stelle int z6 = 0 ; // Die Ziffer an der Zehner-Stelle int z5 = 0 ; // Die Ziffer an der Einer-Stelle TinyGPSPlus gps; unsigned long previousMillis = 0; // will store last time LED was updated const long interval = 800; // interval at which to blink (milliseconds) int punktzwei = 0; SoftwareSerial ss(4, 3); LedControl lc=LedControl(12,11,10,1); void setup() { Wire.begin(); pinMode(9,INPUT_PULLUP); Serial.begin(9600); ss.begin(9600); /* The MAX72XX is in power-saving mode on startup, we have to do a wakeup call */ lc.shutdown(0,false); /* Set the brightness to a medium values */ lc.setIntensity(0,0.1); // 8 ist hell, 0.1 ist abgedunkelt /* and clear the display */ lc.clearDisplay(0); } void loop() { if (digitalRead(9)==LOW) vers = 1 ; // mitteleuropäische Winterzeit MEZ ist UST+1 else vers = 2 ; //mitteleuropäische Sommerzeit MESZ ist UST+2 while (ss.available() > 0) { gps.encode(ss.read()); if (gps.time.isUpdated()) { int kmhgpsr = gps.speed.kmph(); kmphalter = gps.speed.age()+ 1; // int kmhgpsr = 119; if (( kmphalter < 2000 ) && ( kmhgpsr > 9)) { kmhgps = kmhgpsr ; } else { kmhgps = 0 ; } if ( kmhgps > 40 ) { kmhwire = kmhgps ; } else { kmhwire = 0 ;} int minutens = gps.time.minute(); int hourasr = gps.time.hour() + vers; if ( hourasr < 24 ) { houras = hourasr; } else { houras = hourasr - 24; } // Statt 24 Uhr ist es 00 Uhr int z7 = kmhgps / 100; int z6 = ( kmhgps - ( z7 * 100 )) / 10; int z5 = ( kmhgps - ( z7 * 100 ) - ( z6 * 10)); if ( z7 > 0 ) { c7 = z7 ; } else { c7 = ' ' ; } if ( (z6+z7) > 0 ) { c6 = z6 ; } else { c6 = ' ' ; } if ( kmhgps > 0 ) { c5 = z5 ; } else { c5 = ' ' ; } if (gps.time.hour() < ( 10 + vers)) Serial.print(F("0")); Serial.println(kmphalter+1); Serial.print(gps.time.hour() + vers); Serial.print(F(":")); if (gps.time.minute() < 10) Serial.print(F("0")); Serial.println(gps.time.minute()); Serial.println(minutens+3); lc.setDigit(0,0,(minutens - ((minutens / 10 ) * 10)),false); lc.setDigit(0,1,(minutens / 10 ),false); lc.setDigit(0,3,(houras / 10 ),false); lc.setChar(0,7,c7,false); lc.setChar(0,6,c6,false); lc.setChar(0,5,c5,false); //Serial.println(F(":")); unsigned long currentMillis = millis(); if (currentMillis - previousMillis >= interval) { // save the last time you blinked the LED previousMillis = currentMillis; // if the LED is off turn it on and vice-versa: if (punktzwei == 0) { lc.setDigit(0,2,(houras - ((houras / 10 ) * 10)),false); punktzwei = 1; } else { lc.setDigit(0,2,(houras - ((houras / 10 ) * 10)),true); punktzwei = 0; } } if ( kmhwire > 40 ) { Wire.beginTransmission(8); // transmit to device #8 Wire.write(kmhwire); // sends kmhwire Wire.endTransmission(); // stop transmitting } } } }