So we were asked to reproduce the function generator and oscilloscope as a virtual instrument for our final exam. But I'd like to focus on the function generator. The audio generator GW Instek GAG-809/810 has only a single button for the waveform wherein the user would just press it repeatedly to show the desired waveform (i.e., sine wave, square wave). Yeap, the audio generator only have the two waveform but our professor wanted us to add the generator's feature, that is, for the users to be able to display the wave into sawtooth and triangle wave.

So how do we construct it, that different wave forms would display everytime we press the button?

You can count the button presses in a counter.

counter = 0  (at start)
user press button
counter = counter + 1 display waveform  (counter = 1)
user press button
counter = counter + 1 display sawtooth  (counter = 2)
user press button
counter = counter + 1 display triangle wave  (counter = 3)
user press button
counter = counter + 1 (counter = 4)
if(counter == 4)
{
    counter = 1;
    display wave form
}

Maybe this help you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.