comparison examples/basic_analog_output/render.cpp @ 372:db2fe4e1b88e prerelease

Doxygen content added to each example render.cpp. References to AnalogReadFrame etc. removed from doxygen content.
author Robert Jack <robert.h.jack@gmail.com>
date Thu, 09 Jun 2016 18:16:05 +0100
parents 1feb9c23ac57
children 9dc5a0ccad25
comparison
equal deleted inserted replaced
371:361d0c2335cf 372:db2fe4e1b88e
1 /* 1 /*
2 * render.cpp 2 ____ _____ _ _
3 * 3 | __ )| ____| | / \
4 * Created on: Oct 24, 2014 4 | _ \| _| | | / _ \
5 * Author: parallels 5 | |_) | |___| |___ / ___ \
6 |____/|_____|_____/_/ \_\.io
7
6 */ 8 */
7 9
10 /*
11 *
12 * Andrew McPherson and Victor Zappi
13 * Queen Mary, University of London
14 */
15
16 /**
17 \example 3_analog_output
18
19 Fading LEDs
20 -----------
21
22 This sketch uses a sine wave to drive the brightness of a series of LEDs
23 connected to the eight analog out pins. Again you can see the nested `for` loop
24 structure but this time for the analog output channels rather than the audio.
25
26 - connect an LED in series with a 470ohm resistor between each of the analogOut pins and ground.
27
28 Within the first for loop in render we cycle through each frame in the analog
29 output matrix. At each frame we then cycle through the analog output channels
30 with another for loop and set the output voltage according to the phase of a
31 sine tone that acts as an LFO. The analog output pins can provide a voltage of
32 ~4.092V.
33
34 The output on each pin is set with `analogWrite()` within the for loop that
35 cycles through the analog output channels. This needs to be provided with
36 arguments as follows `analogWrite(context, n, channel, out)`. Channel is
37 where the you give the address of the analog output pin (in this case we cycle
38 through each pin address in the for loop), out is the variable that holds the
39 desired output (in this case set by the sine wave).
40
41 Notice that the phase of the brightness cycle for each led is different. This
42 is achieved by updating a variable that stores a relative phase value. This
43 variable is advanced by pi/4 (1/8 of a full rotation) for each channel giving
44 each of the eight LEDs a different phase.
45 */
8 46
9 #include <Bela.h> 47 #include <Bela.h>
10 #include <Utilities.h> 48 #include <Utilities.h>
11 #include <rtdk.h> 49 #include <rtdk.h>
12 #include <cmath> 50 #include <cmath>