User:Inge Hoonte/arduino notes oct 26

From XPUB & Lens-Based wiki
< User:Inge Hoonte
Revision as of 16:41, 26 October 2010 by Inge Hoonte (talk | contribs) (Created page with "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<s...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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);
   }