User:Laura Macchini/prototyping/ArduinoClappingMusic

From XPUB & Lens-Based wiki
char pat[] = "xxx xx x xx ";
char doubled[24];
 
void setup() {
  doubled[0] = 0;
  strcat (doubled, pat);
  strcat (doubled, pat);
  int doublen = strlen(doubled);
  int patlen = strlen(pat);
  int q = 0;
  while (q<100) {
   for (int k=0; k<patlen; k++) {
     int toner = 200;
     if (k%2 == 0) toner = 200;
     else toner = 150;
      for (int p=0; p<patlen; p++) {
          if (pat[p] == 'x') {
              tone(13, 100, 25);
          }
          delay(150);
      }
      for (int p=0; p<patlen; p++) {
                 if (pat[p+k] == 'x') {
              tone(13, toner, 25);
          }
          delay(150); 
    
      }
      
   }
    }
}
 
void loop () {}