Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of ForLoopIteration2 by
main.cpp
00001 /* 00002 For Loop Iteration 00003 00004 Demonstrates the use of a for() loop. 00005 Lights multiple LEDs in sequence, then in reverse. 00006 00007 The circuit: 00008 * LEDs from pins 2 through 11 to ground 00009 00010 created 2006 00011 by David A. Mellis 00012 modified 30 Aug 2011 00013 by Tom Igoe 00014 00015 modified for Nucleo / mbed 12 Aug 2017 00016 by Sheila Ross 00017 00018 This example code is in the public domain. 00019 00020 http://www.arduino.cc/en/Tutorial/ForLoop 00021 */ 00022 00023 #include "mbed.h" 00024 00025 float timer = 0.1; // The higher the number, the slower the timing. 00026 00027 BusOut bar_graph(D2,D3,D4,D5,D6,D7,D8,D9,D10,D11); 00028 00029 int main() { 00030 00031 while(1) { // keep the lights going forever 00032 00033 // light will shift from 0 places to 9 places 00034 00035 for(int lights=1; lights<=(1<<9); lights=(lights<<1)) { 00036 00037 bar_graph = lights; 00038 00039 wait(timer); 00040 } 00041 00042 // now do the same in reverse 00043 00044 for(int lights=(1<<9); lights>=1; lights=(lights>>1)) { 00045 00046 bar_graph = lights; 00047 00048 wait(timer); 00049 } 00050 00051 } 00052 00053 00054 00055 }
Generated on Mon Jul 25 2022 06:46:55 by
1.7.2
