Mercurial > hg > beaglert
diff projects/basic_analog_output/render.cpp @ 269:ac8eb07afcf5
Oxygen text added to each render.cpp file for the default projects. Text includes project explanation from Wiki, edited in places.
Empty project added as a default project.
Doxyfile updated. Each of the project locations added to INPUT configuration option. Consider just watching the whole project file so all new projects are automatically pulled through.
author | Robert Jack <robert.h.jack@gmail.com> |
---|---|
date | Tue, 17 May 2016 15:40:16 +0100 |
parents | 3c3a1357657d |
children | 5433c83ce04e |
line wrap: on
line diff
--- a/projects/basic_analog_output/render.cpp Wed May 11 10:29:23 2016 +0100 +++ b/projects/basic_analog_output/render.cpp Tue May 17 15:40:16 2016 +0100 @@ -1,10 +1,48 @@ /* - * render.cpp + ____ _____ _ _ +| __ )| ____| | / \ +| _ \| _| | | / _ \ +| |_) | |___| |___ / ___ \ +|____/|_____|_____/_/ \_\.io + + */ + +/* * - * Created on: Oct 24, 2014 - * Author: parallels + * Andrew McPherson and Victor Zappi + * Queen Mary, University of London */ +/** +\example 3_analog_output + +Fading LEDs +----------- + +This sketch uses a sine wave to drive the brightness of a series of LEDs +connected to the eight analog out pins. Again you can see the nested `for` loop +structure but this time for the analog output channels rather than the audio. + +Within the first `for` loop in render we cycle through each frame in the analog +output matrix. At each frame we then cycle through the analog output channels +with another `for` loop and set the output voltage according to the phase of a +sine tone that acts as an LFO. The analog output pins can provide a voltage of +~4.092V. + +The output on each pin is set with `analogWriteFrame` within the `for` loop that +cycles through the analog output channels. This needs to be provided with +arguments as follows `analogWriteFrame(context, n, channel, out)`. Channel is +where the you give the address of the analog output pin (in this case we cycle +through each pin address in the for loop), out is the variable that holds the +desired output (in this case set by the sine wave). + +Notice that the phase of the brightness cycle for each led is different. This +is achieved by updating a variable that stores a relative phase value. This +variable is advanced by pi/4 (1/8 of a full rotation) for each channel giving +each of the eight LEDs a different phase. + +*/ + #include <BeagleRT.h> #include <Utilities.h>