/* Powered at 5V (5V LCD), Arduino running at 16MHz D2 - RS (LCD) D3 - R/W (LCD) D4 - E (LCD) D5 - Frequency input D6 - DB4 (LCD) D7 - DB5 (LCD) D8 - DB6 (LCD) D9 - DB7 (LCD) D10 - Gate of NPN transistor (Collector tied to 5V, emitter tied to LCD backlight pin) */ #include // initializieren der interface-pins vom LCD LiquidCrystal lcd(2, 3, 4, 6, 7, 8, 9); //int brightness; unsigned int tovf1 = 0; // Überlaufvariable des Zählers unsigned long frequency = 0, data = 0; // Variable für die gemessene Frequenz unsigned long temp = 0; // Variable zur Frequenzberechnung float messwerte [10]; // Array zur Maximalwertbestimmung unsigned int i=0, j=0; // Variable zur Arrayfüllung int maxwert; // Variable zur Maximalwertbestimmung int anzmesswerte = 10; // Anzahl der Zahlen in dem Array // Timer 1 is our counter // 16-bit counter overflows after 65536 counts // tovfl will keep track of how many times we overflow ISR(TIMER1_OVF_vect) { tovf1++; } void setup() { pinMode(5, INPUT); // This is the frequency input // pinMode(10, OUTPUT); // Backlight control pin // digitalWrite(10, HIGH); // Turn backlight on //----------------------------------------------------------------------------------------------------------------// //Timerprogrammierung// // Timer 1 wird als counter konfiguriert // maximal frequenz is Fclk_io/2 // (recommended to be < Fclk_io/2.5) // Fclk_io is 16MHz TCCR1A = 0; // externe Taktquelle an D5, trigger on rising edge: TCCR1B = (1< 40000000) //40mhz // frequency -= 4294900000; //4,2949ghz //----------------------------------------------------------------------------------------// //??????// //Der Maximalwert des Zählers ist 65536 (2^16) //dieser Wert wird multipliziert mit der Anzahl der Overflow-Werte //temp = 65536*(unsigned long)tovf1; // Add the overflow value to frequency // frequency += temp; //----------------------------------------------------------------------------------------// //----------------------------------------------------------------------------------------------------------------// // Für eine Bessere Anzeige, damit der Wert in der Mitte des Displays steht!// lcd.setCursor(0,1); if (frequency < 100) lcd.print(" "); else if (frequency < 10000) lcd.print(" "); else if (frequency < 1000000) lcd.print(" "); else lcd.print(" "); //----------------------------------------------------------------------------------------------------------------// frequency = frequency / 44; //Teilt die gemessene Frequenz, da der mischer im radarsensor 44hz / 1km/h ausgibt! //----------------------------------------------------------------------------------------------------------------// //Ausgabebefehle für das LCD-Display// lcd.print(frequency); lcd.print(" km/h"); //----------------------------------------------------------------------------------------------------------------// // Rücksetzen aller Variablen den Zählers //TCNT1H = 0; // TCNT1L = 0; //tovf1 = 0; //----------------------------------------------------------------------------------------------------------------// }