also here is the code
#include <stdlib.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(0, 1);
int speakerPin = 9;
int tones[] = {261, 277, 294, 311, 330, 349, 370, 392, 415, 440};
// mid C C# D D# E F F# G G# A
int income = 0;
void setup()
{
mySerial.begin(4800);
while (! Serial); // Wait untilSerial is ready - Leonardo
}
void loop()
{
recieveInputPassword();
}
void recieveInputPassword()
{
if (mySerial.available() > 8)
{
for(int i = 0; i < 8; i++)
{
income = mySerial.read();
mySerial.println(income, DEC);
if(income == 52)
{
giveSignal();
}
}
mySerial.println("SPACE");
}
}
void giveSignal()
{
int i;
for(i = 0; i<3; i++)
{
tone(speakerPin, tones[0]);
delay(1000);
noTone(speakerPin);
}
}