Mercurial > hg > beaglert
diff examples/basic_blink/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 | 02c4ca0e3718 |
children | 9dc5a0ccad25 |
line wrap: on
line diff
--- a/examples/basic_blink/render.cpp Thu Jun 09 17:31:44 2016 +0100 +++ b/examples/basic_blink/render.cpp Thu Jun 09 18:16:05 2016 +0100 @@ -1,3 +1,44 @@ +/* + ____ _____ _ _ +| __ )| ____| | / \ +| _ \| _| | | / _ \ +| |_) | |___| |___ / ___ \ +|____/|_____|_____/_/ \_\.io + + */ + +/* + * + * Andrew McPherson and Victor Zappi + * Queen Mary, University of London + */ + +/** +\example 2_digital_blink + +Blinking an LED +--------------- + +This sketch shows the simplest case of digital out. + +- Connect an LED in series with a 470ohm resistor between P8_07 and ground. + +The led is blinked on and off by setting the digital pin `HIGH` and `LOW` every interval seconds which is set in +`render()`. + +In `setup()` the pin mode must be set to output mode via `pinMode()`. For example: +`pinMode(context, 0, P8_07, OUTPUT)`. +In `render()` the output of the digital pins is set by `digitalWrite()`. For example: +`digitalWrite(context, n, P8_07, status)` where `status` can be equal to +either `HIGH` or `LOW`. When set `HIGH` the pin will give 3.3V, when set to +`LOW` 0V. + +To keep track of elapsed time we have a sample counter count. When the count reaches +a certain limit it switches state to either `HIGH` or `LOW` depending on its current +value. In this case the limit is `context->digitalSampleRate*interval` which +allows us to write the desired interval in seconds, stored in `interval`. +*/ + #include <Bela.h> #include <Utilities.h> #include <cmath>