Wednesday, 11 April 2018

Arduino with Buzzer

Buzzer:

A buzzer or beeper is an audio signalling device,which may be mechanical, electromechanical, or piezoelectric (piezo for short range). Buzzers are used as alarm devices, timers, and confirmation of user input such as a mouse click or keystroke.
medium-piezo-transducer-buzzer-800x609
Buzzer
Mostly Piezoelectric Buzzers are used for projects. It has the ability to generate electricity when mechanical pressure is applied to piezo electric materials and the vice versa is also possible. When subjected to an alternating electric field they stretch or compress, with the frequency of the signal and produce sound.

Hardware Required:

  • Breadboard
  • Buzzer
  • 100 ohm resistor
  • Arduino

Software Required:

  • Arduino UNO

Steps to connect :

Step 1: Connect the buzzer in the breadboard
Step 2: Connect 100 ohm resistor across the buzzer, resistor is used to avoid damage to the buzzer
Step 3: Now connect the positive side of buzzer (RED wire) to the digital pin 9 through resistor
Step 4: Connect the negative terminal of buzzer (Black wire) to the ground.
arduino-with-buzzer
Arduino with Buzzer

Code:
const int buzzerPin = 9;
void setup()
{
Serial.begin(8600);
pinMode(buzzerPin, OUTPUT);
void loop()
{
tone(buzzerPin,1000);
delay(1000);
noTone(buzzerPin);
delay(1000);
}

Coding Explanation:
const int buzzerPin = 9:
It indicates that buzzer is connected to 9th pin of arduino

pinMode(buzzerPin, OUTPUT):
It informs arduino such that buzzer is made as an output

tone(buzzerPin,1000):
It orders the arduino to tone buzzer pin with 1KHz signal

noTone(buzzerPin):
It orders the arduino not to tone buzzer pin

delay(1000) :
This provides a delay of 1 sec between on and off of buzzer

Monday, 9 April 2018

Arduino simple projects- Arduino with LED

Micro-controller becomes an important source in this modern electronic world. So it is necessary for the engineer to update with the new technologies. Arduino has became one of the most important device in embedded field. Here we are going to teach you how to work with arduino.Let us start with simple project.

Hardware Requirements:

  •   Breadboard
  •   LED
  •   220 ohm resistor

Connecting Arduino with LED:


Step 1: Take the breadboard
Step 2: Connect the LED in the breadboard. Note: In LED the long leg indicates positive terminal and the shorter leg indicates the negative terminal.
Step 3: Connect the resistor across the LED as shown in figure. Resistors are connected to avoid damage to LED. Note: Resistor has no positive and negative terminal
Step 4: Connect the resistor terminal across the positive leg of LED to the digital pin 13 of arduino and the other terminal of resistor to the GND of arduino.


Connect LED with Arduino
Arduino connected with LED
             


Software Requirements:

  • Arduino Uno


Codings:


int ledpin=13;
void setup()
{
pinMode(ledPin, OUTPUT);
}
void loop()
{
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
delay(1000);
}


Codings Explanation:


int ledPin=13;
Indicates that LED is connected to the digital pin 13 of arduino.
void setup()
{
pinMode(ledPin, OUTPUT);
}
This indicates the setup to make LED pin as an output pin.
void loop()
{
digitalWrite(ledPin, HIGH);
delay(1000);
digitalWrite(ledPin, LOW);
delay(1000);
}
This indicates the loop to make the LED blink. In this program we coded to make the LED blink with a delay of 1000 ms that is 1 sec.








Thursday, 5 April 2018

Arduino with LM35

LM35- Temperature sensor:

LM35 is a precision IC temperature sensor with its output proportional to the temperature (in degree Celsius).
LM35_02
LM35 terminals


Hardware Required:
  • LM35 sensor
  • Arduino

Software Required:
  • Arduino UNO

Steps to Connect:

Step 1 : Connect 5v supply to the Vcc of arduino

Step 2 : Connect GND of LM35 to GND of arduino

Step 3: Connect Analog pin of LM35 to the Analog pin A0 of arduino



environmentalmonitorfritzing_bb3
Arduino with LM35
The Analog to Digital Converter (ADC) converts analog values into a digital approximation based on the formula ADC Value = sample * 1024 / reference voltage (+5v). So with a +5 volt reference, the digital approximation will = input voltage * 205

Code:

float temp;
int tempPin = 0;

void setup()
{
Serial.begin(9600);
}
void loop()
{
temp = analogRead(tempPin);
temp = temp * 0.48828125;   // to obtain temperature in celsius
Serial.print("TEMPRATURE = ");
Serial.print(temp);
Serial.print("*C");
Serial.println();
delay(1000);
}

Go to serial monitor and see the temperature readings

Tuesday, 3 April 2018

Smoke Detection using arduino

Let us see how to connect smoke sensor with arduino.

Hardware Requirements:

  • Breadboard (optional)
  • Arduino
  • MQ2 Gas sensor

Software Requirements:

  • Arduino uno

MQ2 sensor:

   
The MQ-2 smoke sensor is sensitive to smoke and to the following flammable gases:
  • LPG
  • Butane
  • Propane
  • Methane
  • Alcohol
  • Hydrogen
The resistance of the sensor is different depending on the type of the gas.
The smoke sensor has a built-in potentiometer that allows you to adjust the sensor sensitivity according to how accurate you want to detect gas.

Pin Configuration:

pin configuration of mq2 sensor
   It consists of four pins:
  •    Vcc           -    power supply pin
  •    GND         -    ground
  •    Do             -    Digital pin
  •    Ao             -    Analog pin

Connecting steps:


Step 1: Connect the Vcc pin  of arduino with Vcc of gas sensor.

Step 2: Connect the GND teminals of arduino and gas sensor

Step 3: Connect Do pin  of gas sensor to any of the digital pin you prefer in arduino.
if you want the sensor to show digital reading you can connect it to digital pin or if you want to show analog reading connect analog pin Ao to any of analog pin in arduino.


connecting arduino with gas sensor

Codings:


For Digital output:


int sensor=7;
int gas_value;
void setup()
{

pinMode(sensor,INPUT);
Serial.begin(9600);

}

void loop()
{

gas_value=digitalRead(sensor);
Serial.println(gas_value);
}

Here sensor Do pin is connected to the 7th digital pin of gas sensor and the value 9600 indicates the baud rate.


For Analog output:


float sensor=A0;
float gas_value;
void setup()
{
A0
pinMode(sensor,INPUT);
Serial.begin(9600);

}

void loop()
{

gas_value=analogRead(sensor);
Serial.println(gas_value);
}

Here pin Ao of sensor is connected to Ao pin of arduino and the value 9600 indicates the baud rate.


The output of both mode can be seen in serial monitor using arduino uno.



Arduino with Buzzer

Buzzer: A buzzer or beeper is an audio signalling device,which may be mechanical, electromechanical, or piezoelectric (piezo for short ra...