Simple Melody Demo

int speaker = 8;

void setup() {
tone(speaker, 440);
delay(1000);
noTone(speaker);
}

void loop() {
// no need to repeat the melody.
}

Simple Melody with Looping Demo

int speaker = 8;

void setup() {
tone(speaker, 440);
delay(1000);
noTone(speaker);

delay(3000);
for (int i = 0; i<200; i=i+1){
int note = 30 + i;
tone(speaker, note);
delay(300);
}
noTone(speaker);
}

void loop() {
// no need to repeat the melody.
}

Simple Sensor Demo

void setup() {
Serial.begin(9600);
}

void loop() {
int sensorValue = analogRead(A0);
Serial.println(sensorValue);
delay(100);
}