long randNumber; //Setting all the pins const int sigIn = A3; int certainty = 0; float sigVal = 0; const int waltal = 8; const int ABut = 9; const int ALig = 10; const int AKlax = 2; void setup() { pinMode(AKlax,OUTPUT); //setting pin two for the alert klaxon //setting 5 digital pins to output pinMode(3,OUTPUT); //for the other recording modules. pinMode(4,OUTPUT); pinMode(5,OUTPUT); pinMode(6,OUTPUT); pinMode(7,OUTPUT); pinMode(waltal,OUTPUT); //making the walkie-talkie pin an output pinMode(ABut,INPUT); //And the alert button an input. pinMode(ALig,OUTPUT); //Setting the red alert light to output pinMode(13,OUTPUT); randomSeed( analogRead(A1) ); //Making things really random. Serial.begin(9600); } void loop() { digitalWrite(13,LOW); sigVal = analogRead(sigIn); //reading and storing the data of pin A3 int ABV = digitalRead(ABut); Serial.print("Voltage Output = "); Serial.print(sigVal*5/1023); Serial.println(" "); randNumber = random(3,7); //Getting a random number for the if(ABV == HIGH) { digitalWrite(AKlax,HIGH); for(int i=0;i<6;i++) { digitalWrite(ALig,HIGH); delay(750); digitalWrite(ALig,LOW); delay(750); } delay(10000); } else { if(sigVal >= 748) { certainty++; } else { certainty = 0; } if(certainty >= 3) { //output voice module pins, exept the digitalWrite(7,HIGH); //7th that will play every time delay(2000); digitalWrite(7,LOW); digitalWrite(randNumber,HIGH); delay(7000); digitalWrite(randNumber,LOW); certainty = 0; digitalWrite(waltal,HIGH); delay(30000); digitalWrite(waltal,LOW); delay(10000); } else { } } }