Arduino Function Generator: Square Wave with Variable Duty Cycle
Hi! Not everyone can afford the $2000 for a beautiful function generator like this Agilent 33210A, but everyone deserves to have basic function generation capabilities. So, today I’m going to show you how to make a basic function generator using everyone’s favorite microcontroller: an Arduino Uno!
In this post I’m going to go over some basic code, and how to set up an LED to test it out.
Hardware setup
Set up the LED+resistor with positive lead in pin 9 and the negative plugged into ground. Plug the Arduino into your computer.
We’ll start with the basics:
Square Wave Generator, 50% Duty Cycle
To use this, just change blinkrate
to whatever frequency you’d like the pin to output.