Mercurial > hg > beaglert
diff projects/basic_button/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 | da5ce9876fcc |
children | 5433c83ce04e |
line wrap: on
line diff
--- a/projects/basic_button/render.cpp Wed May 11 10:29:23 2016 +0100 +++ b/projects/basic_button/render.cpp Tue May 17 15:40:16 2016 +0100 @@ -1,9 +1,43 @@ +/* + ____ _____ _ _ +| __ )| ____| | / \ +| _ \| _| | | / _ \ +| |_) | |___| |___ / ___ \ +|____/|_____|_____/_/ \_\.io + + */ + /* * * Andrew McPherson and Victor Zappi * Queen Mary, University of London */ +/** +\example 2_digital_button + +Switching an LED on and off +--------------------------- + +This sketch brings together digital out with digital in. The program will read +a button and turn the LED on and off according to the state of the button. + +- connect an LED in series with a 470ohm resistor between P8_07 and ground. +- connect a 1k resistor to P9_03 (+3.3V), +- connect the other end of the resistor to both a button and P8_08 +- connect the other end of the button to ground. + +You will notice that the LED will normally stay on and will turn off as long as +the button is pressed. This is due to the fact that the LED is set to the same +value read at input P8_08. When the button is not pressed, P8_08 is `HIGH` and so +P8_07 is set to `HIGH` as well, so that the LED conducts and emits light. When +the button is pressed, P8_08 goes `LOW` and P8_07 is set to `LOW`, turning off the LED. + +As an exercise try and change the code so that the LED only turns on when +the button is pressed +*/ + + #include <BeagleRT.h> #include <Utilities.h> #include <cmath>