Microprocessor code for generating and reading sin/sawtooth waves