This is lab2 of 4180 dealing with the extra parts kit.

Dependencies:   mbed LSM9DS1_Library_cal

Jesses_Lab2/Jesses_Main.cpp

Committer:
Jesse Baker
Date:
2016-02-12
Revision:
2:4401fc907d45
Parent:
0:58f21c3e8813
Child:
3:8e9172f7d119

File content as of revision 2:4401fc907d45:

// <- remove this if you want to code this and comment Georges
#include "mbed.h"
#include "DebounceIn.h"
#include "PinDetect.h"

AnalogOut aout(p18);

int main()
{
    const double pi = 3.141592653589793238462;
    const double amplitude = 0.5f;
    const double offset = 65535/2;
    double rads = 0.0;
    uint16_t sample = 0;

    while(1) {
        // sinewave output
        for (int i = 0; i < 360; i++) {
            rads = (pi * i) / 180.0f;
            sample = (uint16_t)(amplitude * (offset * (cos(rads + pi))) + offset);
            aout.write_u16(sample);
        }
    }
}