I am using a particle photon. I want to generate an output which is in the form of a sine function. It’s not a pure sinewave, but a function of sine and cosine. Right now I am using the analog write feature of zerynth. I tried it with analogWrite(), But I am not getting what I exactly need.
Also, Can I use FFT to generate the output ?
import gpio import dac import streams import adc import math buf = bytearray(100) for i in range(len(buf)): buf[i] = 128 + int(127 * math.sin(2 * math.pi * i / len(buf))) myDAC = dac.DAC(D8.DAC) myDAC.start() myDAC.write(buf,400*len(buf),MILLIS,circular=True)
I tried importing the cosine and sine libraries using,
from math import sin
But that didn’t work either.