Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int pinLed[6] = {3,4,5,6,7,8};
- int velocidade;
- int numeroLed;
- int x;
- int entrada;
- void setup() {
- for(x = 0; x <= 5; x = x + 1){
- pinMode(pinLed[x], OUTPUT);
- }
- Serial.begin(9600);
- velocidade = 200;
- }
- void loop() {
- if (Serial.available() > 0){ //Motor ligado para um lado.
- entrada = Serial.read();
- if(entrada == '1' || entrada == 'e'){
- for(numeroLed = 0; numeroLed <= 5; numeroLed = numeroLed + 1){
- digitalWrite(pinLed[numeroLed], HIGH);
- delay(velocidade);
- digitalWrite(pinLed[numeroLed],LOW);
- delay(velocidade);
- if(numeroLed > 4) {
- numeroLed = 0;
- }
- }
- }
- }
- else if (entrada == '2' || entrada == 'd'){ //Motor ligado para o outro lado
- for(numeroLed = 5; numeroLed >= 0; numeroLed = numeroLed - 1){
- digitalWrite(pinLed[numeroLed], HIGH);
- delay(velocidade);
- digitalWrite(pinLed[numeroLed], LOW);
- delay(velocidade);
- if(numeroLed > 4) {
- numeroLed = 5;
- }
- }
- }
- else if (entrada == '0' || entrada == 'a'){ //Motor desligado
- digitalWrite(pinLed[numeroLed], LOW);
- delay(velocidade);
- if(numeroLed < 1) {
- numeroLed = 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement