I am still a newbie to Arduino. I am working on a project where the piezo buzzer is being used and I am struggling with writing the code that would allow the buzzer to play noise for an increasing frequency non stop in a given interval. For example, I want to let the buzzer make noise from 30 to 50 hz. So, it would be going 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Hz and then stop. Basically, the pitch would be increasing as the frequency is increasing and it is continuous such that there would not be gap between changing frequency. I know I must use a tone function for this but I am unsure as to how I would write that. Can you please help me?
These are very low frequencies - are you sure your buzzer will reproduce them? it's the sort of frequency that at least an 8" speaker would be needed to be heard . And would need a few watts to be audible.
For that you would need an amplifier - the arduino output is only good for ~ 10mA at 5v.
The tone () bit is trivial - just vary the frequency part - read the spec.
Or if you want a true-ish sinewave, pwm might be suitable with a low pass filter, or an external DAC
or higher spec arduino and lookup table sw driven source.
regards
Allan