Go Down

Topic: bluetooth with led chase effect project 6 from arduino book (Read 630 times) previous topic - next topic

ironheartbj18

hello, i am working on bluetooth its already connected...  i m trying to figure it out how can i once press '1' automatic led chase effect 12 times forward and back. thats it.. example same as  http://www.youtube.com/watch?v=w-Q1zr0b7Sw i m not sure where should i put add 12 time... let take a look the code....

byte ledPin[] = {8,9,10,11,12,13};
int ledDelay(65);
int direction = 1;
int currentLED = 0;
unsigned long changeTime;

void setup () {
  Serial.begin(9600);
  for (int x=0; x<6; x++) {
    pinMode(ledPin
  • ,OUTPUT); }
        changeTime = millis();
    }
       
    void loop () {
      char bt = Serial.read();
    if ( bt == '1' && (millis() - changeTime) > ledDelay)


     
    {
      changeLED();
        changeTime = millis();
    }}
       
         void changeLED() {
        for (int x=0; x<6; x++){
          digitalWrite(ledPin
  • ,LOW);
        }
        digitalWrite(ledPin[currentLED],HIGH);
          currentLED += direction;
          if(currentLED == 5) {direction = -1;}
          if(currentLED == 0) {direction = 1;}
        }
       
    right now looking like this http://www.youtube.com/my_videos_edit?ns=1&video_id=XRaoxVmxCmQ

Go Up