Clapping music with Arduino: Difference between revisions

From XPUB & Lens-Based wiki
No edit summary
No edit summary
Line 13: Line 13:


void loop () {}
void loop () {}
</source>
<source lang="c">
</source>
</source>


change the argument to the delay...
change the argument to the delay...
for my refined control, try delayMicroseconds
<source lang="c">
void setup()  {               
  int x;
  // initialize the digital pin as an output:
  pinMode(8, OUTPUT);
  for (int i=0; i<1000; i++) {
    digitalWrite(8, HIGH);
    delayMicroseconds(250);
    digitalWrite(8, LOW);
    delayMicroseconds(250);
  }
}
</source>


* http://www.arduino.cc/en/Tutorial/Tone
* http://www.arduino.cc/en/Tutorial/Tone
* Starting point is the Example > Digital > toneMelody
* Starting point is the Example > Digital > toneMelody

Revision as of 19:33, 18 October 2010

Arduino!

void setup()   {                
  pinMode(8, OUTPUT);
  for (int i=0; i<1000; i++) {
    digitalWrite(8, HIGH);
    delay(1);
    digitalWrite(8, LOW);
    delay(1);
  }
}

void loop () {}

change the argument to the delay...

for my refined control, try delayMicroseconds

void setup()   {                
  int x;
  // initialize the digital pin as an output:
  pinMode(8, OUTPUT);
  for (int i=0; i<1000; i++) {
    digitalWrite(8, HIGH);
    delayMicroseconds(250);
    digitalWrite(8, LOW);
    delayMicroseconds(250);
  }
}