User:Birgit bachler/clappingarduino

From XPUB & Lens-Based wiki
< User:Birgit bachler
Revision as of 17:16, 1 November 2010 by Birgit bachler (talk | contribs) (Created page with "<source lang=c> int speakerPin = 13; int thedelay = 100; char pat[] = "xxx xx x xx "; int patlen = strlen(pat); void setup(){ } void loop (){ for(int up=0; up<patlen; ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
int speakerPin = 13;
int thedelay = 100;

char pat[]  = "xxx xx x xx ";
int patlen = strlen(pat);
 
void setup(){
}
 
void loop (){
  
  for(int up=0; up<patlen; up++){
    for(int i=0; i<patlen; i++){

        int i2=i+up;
        if (i2>(patlen-1)){
          i2=i-patlen+up;
        }
        
        if (pat[i] == 'x') tone(speakerPin, 400, thedelay);
        delay(thedelay);
        if (pat[i2] == 'x') tone(speakerPin, 800, thedelay);
        delay(thedelay);    
    }  
    delay(thedelay);
  }
}