comparison examples/basic_button/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
comparison
equal deleted inserted replaced
371:361d0c2335cf 372:db2fe4e1b88e
1 /*
2 ____ _____ _ _
3 | __ )| ____| | / \
4 | _ \| _| | | / _ \
5 | |_) | |___| |___ / ___ \
6 |____/|_____|_____/_/ \_\.io
7
8 */
9
1 /* 10 /*
2 * 11 *
3 * Andrew McPherson and Victor Zappi 12 * Andrew McPherson and Victor Zappi
4 * Queen Mary, University of London 13 * Queen Mary, University of London
5 */ 14 */
15
16 /**
17 \example 2_digital_button
18
19 Switching an LED on and off
20 ---------------------------
21
22 This example brings together digital input and digital output. The program will read
23 a button and turn the LED on and off according to the state of the button.
24
25 - connect an LED in series with a 470ohm resistor between P8_07 and ground.
26 - connect a 1k resistor to P9_03 (+3.3V),
27 - connect the other end of the resistor to both a button and P8_08
28 - connect the other end of the button to ground.
29
30 You will notice that the LED will normally stay on and will turn off as long as
31 the button is pressed. This is due to the fact that the LED is set to the same
32 value read at input P8_08. When the button is not pressed, P8_08 is `HIGH` and so
33 P8_07 is set to `HIGH` as well, so that the LED conducts and emits light. When
34 the button is pressed, P8_08 goes `LOW` and P8_07 is set to `LOW`, turning off the LED.
35
36 As an exercise try and change the code so that the LED only turns on when
37 the button is pressed.
38 */
6 39
7 #include <Bela.h> 40 #include <Bela.h>
8 #include <Utilities.h> 41 #include <Utilities.h>
9 #include <cmath> 42 #include <cmath>
10 #include <rtdk.h> 43 #include <rtdk.h>