//SCULLCOM HOBBY ELECTRONICS //FUNCTION GENERATOR //Software Version 2 #include "LedControl.h" //MAX72XX Seven Segment Library #include //Frequency Counter Library //digital pin 5 is input for frequency // Arduino digital pin 12 is connected to the DataIn // Arduino digital pin 11 is connected to the CLK // Arduino digital pin 10 is connected to LOAD // number of devices is 2 (2 x 4 seven segment display modules) LedControl lc=LedControl(12,11,10,2); unsigned long frq; void setup() { /* The MAX7219 is in power-saving mode on startup, we have to do a wakeup call */ // Initialize the MAX7219 device lc.shutdown(0,false); // Enable display lc.setIntensity(0,10); // Set brightness level of 7 Segment LED's (0 is min, 15 is max) lc.clearDisplay(0); // Clear display register lc.setRow(0,7,B01011011); //letter S lc.setRow(0,6,B01001110); //letter C lc.setRow(0,5,B00111110); //letter U lc.setRow(0,4,B00001110); //letter L lc.setRow(0,3,B00001110); //letter L lc.setRow(0,2,B01001110); //letter C lc.setRow(0,1,B01111110); //letter O lc.setRow(0,0,B01110110); //letter M delay (1000); // delay before going in to frequency counting mode lc.clearDisplay(0); } void printNumber(unsigned long v) { unsigned long ones; unsigned long tens; unsigned long hundreds; unsigned long thousands; unsigned long tenthousands; unsigned long hundredthousands; ones=v%10; v=v/10; tens=v%10; v=v/10; hundreds=v%10; v=v/10; thousands=v%10; v=v/10; tenthousands=v%10; v=v/10; hundredthousands=v; if(frq<100000) { lc.setRow(0,7,B00000000); } else { lc.setDigit(0,7,(byte)hundredthousands,false); } if(frq<10000) { lc.setRow(0,6,B00000000); } else { lc.setDigit(0,6,(byte)tenthousands,false); } if(frq<1000) { lc.setRow(0,5,B00000000); } else { lc.setDigit(0,5,(byte)thousands,false); } if(frq<100) { lc.setRow(0,4,B00000000); } else { lc.setDigit(0,4,(byte)hundreds,false); } if(frq<10) { lc.setRow(0,3,B00000000); } else { lc.setDigit(0,3,(byte)tens,false); } lc.setDigit(0,2,(byte)ones,false); lc.setRow(0,0,B00110111); //print letter H for Hertz } void loop() { // wait if any serial is going on FreqCounter::f_comp=140; // Calibation Value of 140 - change value to calibrate with professional Frequency Counter if one available. FreqCounter::start(1000); // 1000 mSec Gate Time while (FreqCounter::f_ready == 0) frq=FreqCounter::f_freq; printNumber(frq); delay(20); }