User:Inge Hoonte/arduino notes oct 26: Difference between revisions

From XPUB & Lens-Based wiki
(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...")
 
No edit summary
Line 1: Line 1:
int speakerPin = 13;
 
int thedelay = 100;
int speakerPin = 13;
//char keycode = 'x'
int thedelay = 100;
char pat[] = "xxx xx x xx ";
//char keycode = 'x'
int patlen = strlen(pat);
char pat[] = "xxx xx x xx ";
int patlen = strlen(pat);
   
   
void setup() {}
void setup() {}
    
    
void loop () {
void loop () {
   int i = 0;
   int i = 0;
   while (i<strlen(pat)) {
   while (i<strlen(pat)) {

Revision as of 16:42, 26 October 2010

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