Running LED(light emitting diode) with Arduino on loop function driving the LED. below are the wiring instructions.
Electronic Parts Requirements
Jumper Wires
6x LED(light emitting diode)
6x 220k ohm (Resistor)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
/* .:+osysso++:` `+yhs/-` `-+s+` `:/+++++++++` .:/++ooo++/-` .ooooooooooo+: :///////////- `odh/` `:y+` /ddhsooooooo+ /hddhsooooydddh sdddoooooosdddy` `////////////` -hds` `sy. +ddy` .ddd: sddy.dddo +ddd- .-----------` `hds :sssss/ -ossssso-yy` `hdd: oddy `ddd/oddd:......+dddo .++++++++++++ +dd` :sdddh` :ydddddddo +y/ .ddd+........ `hddy:.....:yddy.hdddddddddddy+. ```````````` ydy .hddd/+hdddhydddh/.+yo /hdddddddddd. :shddddddddhs/`+ddd:````-yddy- :ooooooooooo+ odh` sdddooyyyyyhddddyy.sy+ ` `......... ``.... ....` ```...` ` `` `` ` -dd+`::::` .:::- /yy. -oos+:-oos+--oos+: /o `+y o/: o:+/ h:`yos /+-`/+/+ s:y/y. /dd/ `+yy: +//+ +/:+ +/:+ -. `/ -:o.:/:`//+- + +:- :`-+:`://: +`o`+. -yds. `/yys- .`-.. .``` ```` .`` ` ` ``` ``-..` ` :ydy/.`````.-/oyhs: `+++oo+oo+:.+-++/-/ooo+o +:o/oo///:+/ .:oyhhhhhhhso:` `. ``` */ //connect with pin 2 to pin 7. void style_1(void) { unsigned char j; for(j=2;j<=7;j++) { digitalWrite(j,HIGH); delay(200); } for(j=7;j>=2;j--) { digitalWrite(j,LOW); delay(200); } } void flash(void) { unsigned char j,k; for(k=0;k<=1;k++) { for(j=2;j<=7;j++) digitalWrite(j,HIGH); delay(200); for(j=2;j<=7;j++) digitalWrite(j,LOW); delay(200); } } void style_2(void) { unsigned char j,k; k=1; for(j=4;j>=2;j--) { digitalWrite(j,HIGH); digitalWrite(j+k,HIGH); delay(400); k +=2; } k=5; for(j=2;j<=4;j++) { digitalWrite(j,LOW); digitalWrite(j+k,LOW); delay(400); k -=2; } } void style_3(void) { unsigned char j,k; k=5; for(j=2;j<=4;j++) { digitalWrite(j,HIGH); digitalWrite(j+k,HIGH); delay(400); digitalWrite(j,LOW); digitalWrite(j+k,LOW); k -=2; } k=3; for(j=2;j>=1;j--) { digitalWrite(j,HIGH); digitalWrite(j+k,HIGH); delay(400); digitalWrite(j,LOW); digitalWrite(j+k,LOW); k +=2; } } void setup() { unsigned char i; for(i=2;i<=7;i++) pinMode(i,OUTPUT); } void loop() { style_1(); flash(); style_2(); flash(); style_3(); flash(); } |
Download the source code here > 14Core_Runing_light
Starter #5 Running LED With Arduino