act with the physical world. The Arduino environment has been designed to be easy to use for beginners who have no software or electronics experience. However, try to learn more/refresh your knowledge about arduino platfrom, before constructing this circuit.
If you are new to Arduino, this link will help you get started. In addition, there is an active and supportive Arduino community that is accessible worldwide through the Arduino forums. The forums offer project development examples and solutions to problems that can provide inspiration and assistance as you pursue your own projects.
Here is a simple Arduino guide for beginners Panic Alarm circuit consists of two equally important parts. The first part is the ready-made Arduino Microcontroller board, and the second part is an interface circuit which can be wired on a piece of prototyping board.
You can use any standard 9V battery to power the whole circuit, and the Push-ON (push n` hold) switch (S1) to activate the alarm function. An additional Electro-Magnetic Relay (EMR) is also attached to the interface circuit. With the help of this relay, it is easy to energize other (external) high-power blinkers or beepers, if necessary.
// PANIC ALARM - ARDUINO // // by T. K. Hareendran // int rlyPin = 12; // Relay Output Pin int sensPin = 2; // Switch Input Pin int ledPin = 13; // LED output Pin int pzSpeaker = 10; //Piezo-speaker Output Pin int val = 0; // variable for reading the Input Pin status void setup() { pinMode(rlyPin, OUTPUT); // Set Relay as output pinMode(sensPin, INPUT); // Set Switch as input pinMode(pzSpeaker, OUTPUT); // Set Piezo-Speaker as output pinMode(ledPin, OUTPUT); // Set LED as output } void loop(){ val = digitalRead(sensPin); // read input value if (val = HIGH) { // check if the input is HIGH digitalWrite(rlyPin, HIGH); // turn Relay ON digitalWrite(ledPin, HIGH); // turn LED ON playTone(500, 600); delay(100); playTone(500, 800); delay(100); } else { digitalWrite(rlyPin, LOW); // turn Relay OFF digitalWrite(ledPin, LOW); // turn LED OFF playTone(0, 0); delay(300); } } // duration in mSecs, frequency in hertz void playTone(long duration, int freq) { duration *= 1000; int period = (1. 0 / freq) * 1000000; long elapsed_time = 0; while (elapsed_time < duration) { digitalWrite(pzSpeaker, HIGH); delayMicroseconds(period / 2); digitalWrite(pzSpeaker, LOW); delayMicroseconds(period / 2); elapsed_time += (period); } }