#QUESTION 1
from machine import Pin, DAC, Timer
from math import *
dac = DAC(Pin(25))
conversion_factor = (2*pi)/200
sawvalues = []
x = 0
for angle in range (0, 200):
if conversion_factor > 0:
conversion_factor = conversion_factor +1
sawvalues.append(int(conversion_factor))
elif conversion factor < 0:
conversion_factor = concversion factor -1
sawvalues.append(int(conversion_factor))
def handler_0(tim0):
global sawvalues
global x
dac.write(sawvalues[x])
if 0 < x < 50:
x = x+1
elif 50 > x < 100:
x = x-1
elif 100< x > 150 :
x = x+1
elif 150 < x > 200:
x = x-1
else :
x = 0
tim0 = Timer(0)
tim0.init(period=1, mode = Timer.PERIODIC, callback = handler_0)