User:Inge Hoonte/arduino notes oct 26

From XPUB & Lens-Based wiki
int speakerPin = 13;
int thedelay = 100;
//char keycode = 'x'
char pat[] = "xxx xx x xx ";
int patlen = strlen(pat);

void setup() {}
 
void loop () {
 int i = 0;
 while (i<strlen(pat)) {
    if (pat[i] == 'x')   tone(speakerPin, 400, 10);
    delay(thedelay);
    i = i+1;
 }
  //can be written in shorthand:
  /*
  for (i=0; i<12; i+=1)
    if (pat[i] == 'x')   tone(speakerPin, 400, 10);
    delay(thedelay);
   
       }
       */
       
       delay (thedelay*10);
   }