creating code for a square wave output and sine wave output

I hope your lecturer isn't a member here - many are :slight_smile:
You can build a four or five bit DAC easily with an R-2R resistor ladder (useful Google search term)