#include "pitches.h"

const unsigned char SPEAKER_PIN = 4;

void setup() {
  pinMode(SPEAKER_PIN, INPUT);

}

void loop() {
  beep(262, 170);
  delay(50);
  beep(262, 170);
  delay(30);
  beep(294, 150);
  delay(30);
  beep(262, 200);
  beep(294, 200);
  beep(523, 600);
  delay(5000);
}



void beep (int frequencyInHertz, long timeInMilliseconds)
{ // http://web.media.mit.edu/~leah/LilyPad/07_sound_code.html
  int  x;
  long delayAmount = (long)(1000000 / frequencyInHertz);
  long loopTime = (long)((timeInMilliseconds * 1000) / (delayAmount * 2));
  pinMode(SPEAKER_PIN, OUTPUT);
  for (x = 0; x < loopTime; x++) {
    digitalWrite(SPEAKER_PIN, HIGH);
    delayMicroseconds(delayAmount);
    digitalWrite(SPEAKER_PIN, LOW);
    delayMicroseconds(delayAmount);
  }
  pinMode(SPEAKER_PIN, INPUT);
}
ATTINY8520PU
tiny:PB5
tiny:PB3
tiny:PB4
tiny:GND
tiny:PB0
tiny:PB1
tiny:PB2
tiny:VCC
bz1:1
bz1:2