Você está na página 1de 2

F.E.S.

Aragn Alonso Montejano Csar

Temas Selectos de Mecatrnica 2013-I

Proyecto 5 Pelota Rebotando Componentes: -Protoboard -10 Resistencias de 330 -Cable C-20 o C-22 -1 barra de leds -Arduino Uno Rev 3

F.E.S. Aragn Alonso Montejano Csar

Temas Selectos de Mecatrnica 2013-I

//Pelota Rebototando byte ledPin[] = { 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}; int ledDelay(62); int direction = 1; int currentLED = 0; int rebote = 9; unsigned long changeTime; void setup() { for (int x=0; x<10; x++) { pinMode(ledPin[x], OUTPUT); } changeTime = millis(); } void loop() { if ((millis() - changeTime) > ledDelay) { changeLED(); changeTime = millis(); } } void changeLED() { for (int x=0; x<10; x++) { digitalWrite(ledPin[x], LOW); } if (currentLED <= rebote) { digitalWrite(ledPin[currentLED], HIGH); } if ( currentLED == 0 ) {direction = 1;} if (currentLED == rebote) {direction = -1;} currentLED += direction; if ( currentLED == 0 ) {rebote-=1;} if (rebote==0) (rebote=9); }

Você também pode gostar