Clapping music with Arduino
Revision as of 19:55, 18 October 2010 by Michael Murtaugh (talk | contribs)
Hello world.c
Arduino is C!
#include <stdio.h>
main ()
{
printf("hello world\n");
}
Blink music
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);
}
}
tone
- http://www.arduino.cc/en/Tutorial/Tone
- Starting point is the Example > Digital > toneMelody
<source lang="c"> void setup() {
tone(8, 500, 100); delay(100); tone(8, 600, 100); delay(100); tone(8, 700, 100); delay(100); tone(8, 800, 100); delay(100); tone(8, 900, 100); delay(100);
}
void loop() {} </source lang="c">