User:Inge Hoonte/clapping2 arduino

From XPUB & Lens-Based wiki
< User:Inge Hoonte
Revision as of 20:19, 1 November 2010 by Inge Hoonte (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Experimented with the pause between two tones first, but maybe not the right route to go

for (i=0; i<12; i+=1) {
       if (pat[i] == 'x') tone(speakerPin, 440, 40);
       if (pat[i] == ' ') delay(20);
       delay(thedelay);


(beetje later) Tried making two outputs, speakers, but couldn't get it to work (added resistor, didn't work)

int speakerPin = 13;
int speakerPin2 = 8;
int thedelay = 10;


char pat[] = "xxx xx x xx ";
int patlen = strlen(pat);

void setup()
{ //imaginary content
}
void loop ()
{
   int i;
   int i2;
   int j;
   
   for (j=0; j<patlen+1; j++) {
   
     for (i=0; i<patlen; i++) {
       if (pat[i] == 'x') tone(speakerPin, 440, 50);
       delay(40);
       if (pat[i2] == 'x') tone(speakerPin2, 800, 50);
       
     }
       {
        // for (i2=patlen-1; i2<patlen; i
          // if (pat[i2] == 'x') tone(speakerPin, 500, 10);
       }
   }
   
   delay(thedelay*10);
}


Hm. Maybe change pattern? Make two patterns. But different than this.

char pat[] = "x";
char pat2[] = "xx xx x xx ";
int patlen = strlen(pat);
int pat2len = strlen(pat2);
 
void setup()
{ //imaginary content
}
void loop ()
{
   int i;
   int i2;
   int j;
   
   for (j=0; j<patlen; j++) {
     for (i=0; i<patlen+pat2len; i++) 
         if (pat[i] or pat2[i] == 'x') tone(speakerPin, 440, 50);
         delay(10);