Uno + GLCD + 2 Buttons = Frequency Generator 0 Hz -1 MHz

As an example I added a frequency generator to (GLCD version of m2tklib).
Only a graphics display and some input buttons are required for a nice frequency generator with adjustable duty. The display also shows the hardware values, because not all values can be created by the ATMEGA.


Nice job! That could be very useful!


Hallo Oliver, Dein Projekt ist genau das, was ich gesucht habe, Danke dafür.

Leider funktioniert (bei mir) irgendetwas nicht richtig. Arduino 1.0.1 und m2tklib_arduino_glcd_1.08. der Rahmen um die Eingabefelder ist viel zu klein, Real Freq und Real Duty = 0 Arduino 1.0.1 und m2tklib_arduino_glcd_1.05. der Rahmen um die Eingabefelder passt, Real Freq und Real Duty = 0, Lautsprechen an Pin 3 kein Signal

es wäre toll, wenn es dafür eine Lösung gibt.

Gruss Kurti

Hallo Kurti

Please excause for switching back to english.

Many many thanks for reporting that bug. I have corrected M2tklib and uploaded the new release 1.08.1 Please download v1.08.1 from

I have verified that the singal is available at pin 3 (Arduino Duemilanove)

Thanks, Oliver

It looks like you are driving an 8 ohm speaker directly from an Arduino pin. The datasheet recommends no more then 40mA per pin. 5v / 8 ohms = 625mA. Far too high. I recommend putting a resistor of around 220 ohms in series but even 100 ohms will be better then nothing. Better yet is to use a transistor driver with base resistor.

Hi, I got it, it's working !

the program is: uint8_t uiKeySelectPin = 0; uint8_t uiKeyDownPin = 1; uint8_t uiKeyUpPin = 2;

the function is: Switch at pin 0 = +1 and Enter Switch at pin 1 = select Switch at pin 2 = no function

You have to push the select-button to put the cursor to the right position. Then push the +1 button to select the number. After making the setting push the select button until Apply is highlighted. Then push the +1 button ( enter )

Thanks for this sketch Kurti


You are right, the resistor will add some safety to the hardware. However, to my knowledge, the current is also limited by the controller itself.


In order to use all three buttons, you need to exchange the button handler. Instead of M2tk m2(&top_el_gridlist, m2_es_arduino, m2_eh_2bs, m2_gh_glcd_ffs); use M2tk m2(&top_el_gridlist, m2_es_arduino, m2_eh_4bs, m2_gh_glcd_ffs);


Hi, I tried your fix and it's working, the switch at pin 2 has a function.

I checked the signal at pin 3 with my osci: - the calculation of the real duty has nothing in common with the signal ( Test 300 Hz, 50 Duty -> Real Freq.: 300, Real Duty 102, Frequency changed to 800 Hz, Real Duty changes to ) - the Frequency Generator only works above 60 Hz

Thanks for your tries Kurti

Hi Guys,

Interesting project.
Where do I get the GLCD library & will it work with the Adafruit 1.8" ST7735 TFT LCD? This display uses same SPI interface pins.
If display won’t work with GLCD library then could I substitute the Adafruit GFX.h , Adafruit St7735.h and SPI.h

My project is to generate 0-200 pulses per second with display. Uno will be driving speaker with transistor driver. An ultrasonic cardiac transducer will be placed on thin foam on top of speaker and pulses used to simulate pulse detection. I have already made a simple version using 555IC, but stability is not high & no digital display.

Any tips would be appreciated.


The graphics library is here:
The display is a simple KS0108 based monochrome display.