Pages: [1]   Go Down
Author Topic: bluetooth with led chase effect project 6 from arduino book  (Read 581 times)
0 Members and 1 Guest are viewing this topic.
san Antonio
Offline Offline
Jr. Member
**
Karma: 0
Posts: 71
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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  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
Logged

Pages: [1]   Go Up
Jump to: