Beruflich Dokumente
Kultur Dokumente
Instruction;
1) Connect all jumper wire as shown in diagram.
3) Connect IR Phototransistor (dark) to digital pin 2. Make sure shorter lead connected to digital pin
2 and longer lead to Ground.
Parts List;
1) 1x 16×2 parallel LCD display (compatible with Hitachi HD44780 driver)
2) 1x Arduino
3) 1x 10kΩ potentiometer
4) 1x 10kΩ resistor
5) 1x IR LED
6) 1x IR Phototransistor
7) Jumper wire
* Optical Tachometer
*
* Uses an IR LED and IR phototransistor to implement an optical tachometer.
* The IR LED is connected to pin 13 and ran continually.
* Pin 2 (interrupt 0) is connected across the IR detector.
*
* Code based on: www.instructables.com/id/Arduino-Based-Optical-Tachometer/
* Coded by: arduinoprojects101.com
*/
void rpm_fun()
{
//Each rotation, this interrupt function is run twice, so take that into
consideration for
//calculating RPM
//Update count
rpmcount++;
}
void setup()
{
Serial.begin(9600);
lcd.begin(16, 2); // intialise the LCD
//Turn on IR LED
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, HIGH);
rpmcount = 0;
rpm = 0;
timeold = 0;
}
void loop()
{
//Update RPM every second
delay(1000);
//Don't process interrupts during calculations
detachInterrupt(0);
//Note that this would be 60*1000/(millis() - timeold)*rpmcount if the
interrupt
//happened once per revolution instead of twice. Other multiples could be used
//for multi-bladed propellers or fans
rpm = 30*1000/(millis() - timeold)*rpmcount;
timeold = millis();
rpmcount = 0;
Note:
This code reading rpm with 2 propeller at the motor. This mean 2 cut of the infrared
beam will count as 1 revolution. You can modify this line to suit your use;
rpm = 30*1000/(millis() – timeold)*rpmcount;
As shown in the above tachometer circuit, it contains Arduino Pro Mini, IR sensor module,
buzzer and LCD. Arduino controls the whole the process like reading pulse that IR sensor
module generate according to object detection, calculating RPM and sending RPM value
to LCD. IR sensor is used for sensing object. We can set sensitivity of this sensor module
by inbuilt potentiometer situated on IR module. IR sensor module consist an IR transmitter
and a photo diode which detects or receives infrared rays. IR transmitter transmits infrared
rays, when these rays fall on any surface, they reflect back and sensed by photo diode (You
can understand more about it in this Line Folloewr Robot). The output of photo diode is
connected to a comparator, which compare photo diode output with reference voltage and
result is given as output to arduino.
IR sensor module output pin is directly connected to pin 18 (A4). Vcc and GND are
connected to Vcc and GND of arduino. A 16x2 LCD is connected with arduino in 4-bit mode.
Control pin RS, RW and En are directly connected to arduino pin 2, GND and 3. And data
pin D4-D7 is connected to pins 4, 5, 6 and 7 of arduino. A push button is also added in this
project. When we need to count RPM we press this button to start this Arduino Tachometer
to count RPM for five seconds. This push button is connected to pin 10 of arduino with
respect to ground.
#include <LiquidCrystal.h>
LiquidCrystal lcd(3, 2, 4, 5, 6, 7);
#define sensor 18
#define start 10
int delay1()
{
//unsigned int long k;
int i,j;
unsigned int count=0;
for(i=0;i<1000;i++)
{
for(j=0;j<1227;j++)
{
if(digitalRead(sensor))
{
count++;
while(digitalRead(sensor));
}
}
}
return count;
}
void setup()
{
pinMode(sensor, INPUT);
pinMode(start, INPUT);
pinMode(13, OUTPUT);
lcd.begin(16, 2);
lcd.print("Techometer");
lcd.setCursor(0,1);
lcd.print("Circuit Digest");
delay(2000);
digitalWrite(start, HIGH);
}
void loop()
{
unsigned int time=0,RPM=0;
lcd.clear();
lcd.print(" Please Press ");
lcd.setCursor(0,1);
lcd.print("Button to Start ");
while(digitalRead(start));
lcd.clear();
lcd.print("Reading RPM.....");
time=delay1();
lcd.clear();
lcd.print("Please Wait.....");
RPM=(time*12)/3;
delay(2000);
lcd.clear();
lcd.print("RPM=");
lcd.print(RPM);
delay(5000);
}
#include<LiquidCrystal.h>
LiquidCrystal lcd(12,11,6,5,4,3);
int pwm=9;
int pot=A0;
float value=0;
int percent;
float rev=0;
int rpm;
int oldtime=0;
int time;
rev++;
void setup()
void loop()
delay(1000);
rev=0;
value=value/4;
lcd.clear();
lcd.setCursor(0,0);
lcd.print("___TACHOMETER___");
lcd.setCursor(0,1);
lcd.print(rpm);
lcd.print(" RPM");
lcd.print(" ");
lcd.print(percent);
lcd.print("%");
attachInterrupt(0,isr,RISING);
Notes.
The arduino board can be powered using a 9V supply through the external power jack.
The 5V needed at some parts of the circuit can be tapped from the 5V source on the arduino board.
The fan I used was rated 9V/100mA. The transistor 2N2222 can handle only upto 800mA. Keep this in
mind while selecting the load.
The LCD module used was JHD162A.
POT R5 can be used to adjust the contrast of the LCD display. When connected first, the LCD may not
show up anything. Adjust the R5 until you get the display. The optimum voltage at the wiper of R5 is
between 0.4 to 1V.
The IR photo transistor and the IR diode both were taken from an LTH-1550 photo interrupter module.
The lateral surface of the photo transistor must be masked using a tape.
The sensor arrangement is shown in the figure below.
How to Build a Simple Arduino
Calculator?
A Calculator is a device that is used to perform simple arithmetic operations to complex
mathematical calculations. The rise of calculators can be seen from devices like Abacus to
credit card sized complex electronic solid state devices in the modern day usage.
Apart from small calculators, which can be used to perform simple arithmetic calculations,
calculators also come in complex scientific outlook that can perform various mathematical and
statistical operations like trigonometry, algebra, calculus, etc. But such complex scientific
calculators can be very costly.
Components
Arduino UNO
16 x 2 LCD Display
4 x 4 Matrix Keypad Module or 16 Push buttons
10 KΩ Potentiometer
Bread board ( Prototyping board )
Connecting wires
Component Description
Arduino UNO:
The Microcontroller part of the project is the Arduino UNO. It controls the LCD and matrix
keypad and also performs the necessary calculations as per the user input.
16 x 2 LCD Display:
It is a simple alpha – numeric display module that is used to display the welcome messages,
user inputs and finally the output of the calculations.
4 x 4 Matrix Keypad:
Keypads are a part of Human Machine Interface and play really important role in embedded
systems where human input is needed. Matrix Keypads are commonly used in calculators,
telephones etc. where a number of input switches are required.
Construction of a 4X4 keypad is really simple. It consists of 16 buttons or switches arranged in
the form of an array containing four rows and four columns. One end of the pushbutton is
connected to one row, and the other end is connected to one column.
Circuit Design
The design of the circuit is simple to understand but a little bit messy to implement as it involves
a lot of connections and wires. The design of the circuit is explained here.
First, the connection of LCD display to Arduino UNO. LCD is used in 4 – bit mode and hence,
only 4 data connections are needed. The data pins D4 through D7 (Pins 11 – 14) are connected
to digital I/O pins 2 through 5 of the Arduino.
Then, we need to connect the three control pins of LCD i.e. RS, RW and E. RS (Pin 4) is
connected to Pin 0 of the Arduino. E (Pin 6) is connected to Pin 1 of the Arduino. RW (Pin 5) is
connected to ground.
Note:
RS and E are connected to Pins 0 and 1 of Arduino which are usually associated with serial
communication. We must be careful while programming the device and hence we must
disconnect these two connections while we are programming Arduino UNO.
The next connections are with respect to power supply of LCD. Pin 1 (VSS) is connected to
ground and Pin 2 (VDD) is connected to 5V supply. Pin 3 (VEE) is connected to a POT for
adjusting the contrast of display.
Pin 15 and Pin 16 are supply pins for backlight LED. They must be connected to 5V and ground
supply.
The next connection is with respect to matrix keypad. The 4 row pins of the keypad (row 1 to
row 4) are connected to pins 13 through 10 of Arduino UNO and the 4 column pins (col 1 to col
4) are connected to pins 9 through 6 of Arduino UNO.
Working Process
A simple calculator is designed in this project using Arduino UNO board and a keypad matrix.
The working of the project is explained here.
The keypad in the project consists of 4 rows and 4 columns and the structure is similar to the
image shown below.
A special library called “Keypad.h” is used in order to find out which key is pressed. This library must
be downloaded separately and must be added to Arduino IDE.
When the key is determined, relevant operations like addition, subtraction, multiplication and division
can be performed. A clear screen (of LCD display) button is also included.
Even though the library does the most of the work, we can understand the processing of determining
the key.
As mentioned in the circuit design, the rows of the keypad are connected to pins 13 – 10 of Arduino
and columns of keypad are connected to pins 9 – 6 of Arduino.
All the row pins are pulled high and all the column pins are pulled low. From now onwards, the
Arduino waits for the column pin to become HIGH, which happens if a key is pressed.
Consider, if a key is pressed, the switch closes the connection between the corresponding row and
column. Due to the flow of current from high to low potential, the column will become high.
This change in potential at the column, makes the Arduino to understand that the key corresponding
to the particular column is pressed.
Now it’s time to find the row. Instead of giving HIGH signal to all the rows at once, Arduino will enable
HIGH to one row at a time and check whether there is a HIGH signal detected on the column. If there
is no HIGH signal detected on the corresponding column, Arduino will scan for the next row.
This process will repeat until there is a HIGH signal detected on the corresponding column. Once if
the HIGH signal is detected on the corresponding column, thus the row is identified.
From the outside, this key detection process seems to be taking long time but really the time taken to
complete all the above mentioned process will be in micro seconds. But the average time a human
takes for pushing a button is in milli seconds. That’s why, the key detection process will start when
the key is pressed and completes before the key is released.
Advantages
A simple arithmetic calculator is implemented in this project using Arduino UNO, matrix keypad and LCD.
Can be extended to perform complex calculations, but the logic must be carefully designed in order to
solve those calculations. This may even result in increased number of switches.
#include <LiquidCrystal.h>
#include <Keypad.h>
LiquidCrystal lcd(0, 1, 2, 3, 4, 5);
const byte ROWS = 4;
const byte COLS = 4;
void setup()
{
lcd.begin(16,2);
lcd.setCursor(0,0);
lcd.print("Electronics Hub ");
lcd.setCursor(0,1);
lcd.print(" Presents ");
delay(5000);
lcd.setCursor(0,0);
lcd.print(" Arduino based ");
lcd.setCursor(0,1);
lcd.print(" Calculator" );
delay(5000);
lcd.clear();
}
void loop(){
char key = myKeypad.getKey();
else if (presentValue == false && key != NO_KEY && (key == '/' || key == '*' || key == '-' || key ==
'+'))
{
if (presentValue == false)
{
presentValue = true;
op = key;
lcd.setCursor(15,0);
lcd.print(op);
}
}
We generally use an oscilloscope to depict the signal, calculate the time period of the
signal and finally convert it to calculate the frequency of the signal. But, oscilloscopes
are very expensive and everyone cannot afford it.
Hence, a simple Digital Frequency Counter can be built which might come in handy to
measure the frequency of a clock signal, for example.
In this project, an Arduino based Digital Frequency Counter is designed to measure the
frequency of an incoming signal.
Components
Arduino Part
Arduino UNO
16 X 2 LCD Display
Prototyping Board
Connecting wire
Power Supply (adapter or battery)
NE555 Timer IC
10 KΩ Potentiometer X 2
100 nF Capacitor (Code: 104)
1 µF / 16V Electrolytic Capacitor
5V Power Supply (12V is not suitable as it might damage Arduino board).
Connecting wires
Prototyping Board
Component Description
Arduino UNO: The ATmega 328P microcontroller based Arduino UNO is the main part
of the project. It captures the time period of the incoming signal and calculates the
frequency of the signal.
555 Timer IC: In this project, the 555 Timer IC is used as a pulse generator i.e. it works
in astable mode.
16 X 2 LCD: The 16×2 LCD module is used to display the key information like welcome
(or any custom) messages and the calculated frequency of the signal.
Circuit Design
The design of the Frequency Counter using Arduino UNO can be divided in to two parts:
The Arduino part, where the processing of the signal’s information takes place and the
Signal Generator part, where the signal whose frequency to be measured is generated.
Arduino Circuit
Arduino part of the project consists of Arduino UNO board and a 16 X 2 LCD Display.
Pins 1 and 2 of the LCD (Vss and Vdd) are connected to ground and 5V supply
respectively. Pin 3 (Vee), which is used to adjust the contrast of the display, is
connected a Potentiometer.
Pins 4 and 6 (RS and E) of the LCD are connected to digital I/O Pins 2 and 3 of the
Arduino. Pin 5 (RW) of the LCD is connected to ground.
Pins 11 to 14 (D4 to D7) i.e. the data pins of the LCD are connected to the digital I/O
pins 4 to 7 of Arduino. Pins 15 and 16 of the LCD are supply pins of the backlight LEDs
and are connected to ground and 5V (Pin 16 to 5V through a 1KΩ resistor) respectively.
A 10KΩ Potentiometer is connected between the power supply and Pin 7 (Discharge).
The wiper terminal of the potentiometer is connected to Pin 7.
Similarly, another 10KΩ Potentiometer is connected between pins 7 and 6. This time,
the wiper of the potentiometer is connected to Pin 6.
A 100nF capacitor is connected between pin 6 and ground. By selecting this resistor,
the frequency of the output signal, which can be taken from Pin 3 (Output), will be in the
range of 480 Hz to 48 KHz.
Note: The power supply to the signal generator circuit should be only 5V. This is
because, the voltage of the generated pulse will be same as that of the input voltage
and the Arduino UNO board (or ATmega 328p microcontroller to be precise) can
tolerate a maximum of 5.5V at its input pins.
Working Principle of the Project
The aim of the project is to design a simple digital frequency counter circuit using
Arduino UNO and 555 Timer IC. The working of the project is very simple and is
explained here.
In the Arduino, we make use of a function called “pulseIn ();” The function pulseIn can
be used to read either LOW or HIGH pulse on a digital I/O pin and returns the length of
the pulse in microseconds.
For example, if the pulseIn function is used to read a HIGH pulse on a pin, it waits for
the pin to go HIGH. Once the pin goes HIGH, it starts the timer and runs until the pin
goes LOW. The duration (in microseconds) of this HIGH pulse is then returned.
In our project, we are calculating the duration of the HIGH pulse and LOW pulse and by
adding them together, we get the period of the input signal. Inverse of this value gives
the frequency of the signal which is displayed on the LCD.
Note:
As mentioned earlier, the range of frequency of the signal generated by the 555 Tier can
be changed by changing the value of the capacitor.
Arduino can only detect incoming pulses i.e. the incoming signal can be either square or
rectangular. Not all test signals can be in the form of pulses. Hence, we can use a Schmitt
Trigger to convert the any incoming to a pulse.
Also note that the output of the Schmitt Trigger IC (74LS14) is an inverted signal of the
input signal.
Applications
A simple frequency counter, using simple components is designed that can be used to
measure the frequency of a pulse without the need of an oscilloscope.
Multiple ranges of frequencies can be measured by selecting suitable components.
Frequencies of all types of test signals can be calculated by adding a Schmitt Trigger
between the generated signal and Arduino.
#include <LiquidCrystal.h>
int pulseHigh; // Integer variable to capture High time of the incoming pulse
int pulseLow; // Integer variable to capture Low time of the incoming pulse
float pulseTotal; // Float variable to capture Total time of the incoming pulse
void setup()
pinMode(pulsePin,INPUT);
lcd.begin(16, 2);
lcd.setCursor(0,0);
lcd.print("Electronics Hub");
lcd.setCursor(0,1);
delay(5000);
void loop()
lcd.setCursor(0,0);
lcd.print("Frequency is ");
lcd.setCursor(0,1);
lcd.print(" ");
pulseHigh = pulseIn(pulsePin,HIGH);
pulseLow = pulseIn(pulsePin,LOW);
lcd.setCursor(0,1);
lcd.print(frequency);
lcd.print(" Hz");
delay(500);
Circuit Diagram
The circuit design of solar tracker is simple but setting up the system must be done
carefully.
Four LDRs and Four 100KΩ resistors are connected in a voltage divider fashion and the
output is given to 4 Analog input pins of Arduino.
The PWM inputs of two servos are given from digital pins 9 and 10 of Arduino.
Working
LDRs are used as the main light sensors. Two servo motors are fixed to the structure
that holds the solar panel. The program for Arduino is uploaded to the microcontroller.
The working of the project is as follows.
LDRs sense the amount of sunlight falling on them. Four LDRs are divided into top,
bottom, left and right.
For east – west tracking, the analog values from two top LDRs and two bottom LDRs
are compared and if the top set of LDRs receive more light, the vertical servo will move
in that direction.
If the bottom LDRs receive more light, the servo moves in that direction.
For angular deflection of the solar panel, the analog values from two left LDRs and two
right LDRs are compared. If the left set of LDRs receive more light than the right set, the
horizontal servo will move in that direction.
If the right set of LDRs receive more light, the servo moves in that direction.
Setup
Step-1
Take cardboard. Make a hole in the middle and four holes on four sides so that LDR fit
into that.
Stick the solar panel to the cardboard and bring two wires of the panel out as shown.
Step 2
Now cut one of the two leads of the LDR so that one lead is shorter and other is longer.
Insert these four LDRs into four holes as shown.
Bend the straight Perforated metal strip as shown below.
Place the bent metal strip on the back side of the cardboard
Apply glue to the LDR to fix them firmly.
Step 3
Solder the two leads of LDR as shown
To the other ends of LDR Solder resistors of 10k ohm
Join the four leads of the 4 LDRs by connecting with a wire.
Step4
Now take a bus wire.This is used to connect the Outputs of four LDRs to Arduino board.
Insert it into metal strip as shown in the image.
Now Solder the four wires to four LDRs at any point between LDR and resistor.
Step 5
Insert another two wire bus into the perforated metal strip as shown.This is used for
supplying Vcc and GND to LDR circuit.
Solder one wire to the leads of LDRs which are connected to resistors and other wire to
the other leads.
Short the leads of LDRs connected to resistors using a wire as shown.
Step 6
Now connect a servo motor to the Perforated metal strip using Screw.
Apply glue to the servo to fix it firmly.
Step 7
Take another straight Perforated metal strip and bend it as shown in the figure.
Step 8
Now place the set up of solar panel and first servo motor to the metal strip of second
servo motor as shown.
CODE:
#include <Servo.h>
//defining Servos
Servo servohori;
int servoh = 0;
Servo servoverti;
int servov = 0;
//Assigning LDRs
void setup ()
servohori.attach(10);
servohori.write(0);
servoverti.attach(9);
servoverti.write(0);
delay(500);
void loop()
servoh = servohori.read();
servov = servoverti.read();
// calculating average
servoverti.write(servov +1);
servov = servovLimitHigh;
delay(10);
servoverti.write(servov -1);
servov = servovLimitLow;
delay(10);
}
else
servoverti.write(servov);
servohori.write(servoh +1);
servoh = servohLimitHigh;
delay(10);
servohori.write(servoh -1);
servoh = servohLimitLow;
delay(10);
else
servohori.write(servoh);
}
delay(50);
The story of Servo Motor is entirely different from that of a DC Motor. A Servo Motor is a
type of actuator that provides high precision control of linear or angular position. A
typical servo motors consists of four things (or parts): a DC Motor (or AC Motor), a gear
unit, a position and speed sensing device and a control unit.
Servo Motors are used in applications where very high precision motion is required like
assembly robots, computer numeric controls etc.
Circuit Diagram
Components
Arduino UNO Board
Tower Pro SG90 Servo Motor
10KΩ Potentiometer
5V Power Supply
Breadboard
Connecting wires
Component Description
Arduino UNO
The main processing module of the project is Arduino UNO board. Its features like
Analog to Digital Converter (ADC) and Pulse Width Modulation (PWM) are used in this
project.
Servo Motor
As mentioned in the introduction, a servo motor is a type of DC motor which is used for
precision control. Servo motors are available as both AC Servo motors and DC
Servomotor with each type having its own areas of applications.
A simple servo motor (as the one used in this project) consists of a small DC motor, a
potentiometer for providing position feedback, a gear system for increased torque and a
control system.
Typically, simple servo motors consists of three wires. These are usually color coded as
Red, Brown and Orange (may vary with different models). The Red wire is used for
supply, the Brown wire is used for ground and the Orange wire is used for control
signal.
Here, the control signal will determine the position of the servo motor’s shaft. The
control signal is usually a PWM signal but this PWM signal is not used to control the
speed of the motor as in case of a DC Motor. But rather, it is used to determine the
position of the servo meter.
The DC Motor in the servo motor is powered as per the control signal it receiver. As per
the feedback from the position sensing system (like a potentiometer), when the servo
achieves the desired position, the power to the motor is terminated.
Even though the power supply to the motor inside the servo motor is not constant, the
overall power should be constant as the servo motor has a dedicated system that
controls the power.
The servo motor used in this project is Tower Pro SG90. It is a small but powerful servo
motor that can produce a torque of 1.8 kgf.cm.
Circuit Design
The main components of this project are Arduino UNO board and servo motor. The
design of the circuit is pretty straight forward. As mentioned earlier, a servo motor has
three wires: two for electrical connection and one for control signal.
So, connect the red wire to +5V supply and brown wire to ground. As the control signal
is a PWM (in case or servo motors, it is technically Pulse Position Modulation or PPM),
the control wire or orange wire must be connected to any of the PWM output pins of the
Arduino UNO board. In this project, we are connecting the control wire of the servo
meter to Pin 11 of the Arduino.
In order to manually control the position of the servo motor, we need to use a
potentiometer. The wiper terminal of the 10KΩ POT is connected to the analog input pin
A0 of the Arduino UNO. The other terminals of the potentiometer are connected to +5V
supply and ground respectively.
Working
The aim of this project is to demonstrate the working of a servo meter with the help of
Arduino UNO board. The working of the project is explained here.
Here, we implemented two different modes of operating the servo motor. In the first
mode, the Arduino board (or the microcontroller) will continuously sweep the servo
motor at +180 degrees and -180 degrees i.e. 180 degrees in clock wise direction and
180 degrees in anti-clock wise direction.
In the second mode, the position of the servo motor is controlled manually using a
potentiometer. Even in this mode the servo motor can be rotated at +180 and -180 but
the position can be precisely controlled using the potentiometer.
But for more precise control, we need to use the second mode and the following circuit
must be used.
The potentiometer is connected to the analog input pin of the Arduino. The position of the
potentiometer will determine the duty cycle of the PWM signal and this value, which will
be in the range of 0 to 1023 (since Arduino UNO has a 10-bit ADC), is mapped to an
angular position of 0 to 180 degrees. As a result, each degree of rotation of the servo
motor can be precisely controlled by adjusting the position of the potentiometer.
Applications
Servo Motors are one of the main components in precision control systems.
Arduino based servo motors can be used small robotic applications, angular control of
security cameras, etc.
They can also be used in solar tracking system for increasing the efficiency of solar
energy.
#include <Servo.h>
Servo servosweep;
void setup()
servosweep.attach(11);
void loop()
servosweep.write(pos);
delay(20);
servosweep.write(pos);
delay(20);
}
}
#include <Servo.h>
Servo servoknob;
int potpin = 0;
int val;
void setup()
{
servoknob.attach(11);
}
void loop()
{
val = analogRead(potpin);
val = map(val, 0, 1023, 0, 180);
servoknob.write(val);
delay(15);
}
Mobile phone is a revolutionary invention of the century. It was primarily designed for
making and receiving calls & text messages, but it has become the whole world after
the Smart phone comes into the picture. In this project we are building a home
automation system, where one can control the home appliances, using the
simple GSM based phone, just by sending SMS through his phone. In this project,
no Smart phone is needed, just the old GSM phone will work to switch ON and OFF
any home electronic appliances, from anywhere. You can also check some
more Wireless Home
Working Explanation
In this project, Arduino is used for controlling whole the process. Here we have used GSM
wireless communication for controlling home appliances. We send some commands like
“#A.light on*”, “#A.light off*” and so on for controlling AC home appliances. After receiving
given commands by Arduino through GSM, Arduino send signal to relays, to switch ON or
OFF the home appliances using a relay driver.
Circuit Components:
Arduino UNO
GSM Module
ULN2003
Relay 5 volt
Bulb with holder
Connecting wires
Bread board
16x2 LCD
Power supply
Cell phone
Here we have used a prefix in command string that is “#A.”. This prefix is used to identify
that the main command is coming next to it and * at the end of string indicates that message
has been ended.
When we send SMS to GSM module by Mobile, then GSM receives that SMS and sends it
to Arduino. Now Arduino reads this SMS and extract main command from the received
string and stores in a variable. After this, Arduino compare this string with predefined string.
If match occurred then Arduino sends signal to relay via relay driver for turning ON and
OFF the home appliances. And relative result also prints on 16x2 LCD by using appropriate
commands.
Here in this project we have used 3 zero watt bulb for demonstration which indicates Fan,
Light and TV.
Below is the list of messages which we send via SMS, to turn On and Off the Fan, Light
and TV:
5 #A.tv on* TV ON
GSM Module:
GSM module is used in many communication devices which are based on GSM (Global
System for Mobile Communications) technology. It is used to interact with GSM network
using a computer. GSM module only understands AT commands, and can respond
accordingly. The most basic command is “AT”, if GSM respond OK then it is working good
otherwise it respond with “ERROR”. There are various AT commands like ATA for answer
a call, ATD to dial a call, AT+CMGR to read the message, AT+CMGS to send the sms etc.
AT commands should be followed by Carriage return i.e. \r (0D in hex), like “AT+CMGS\r”.
We can use GSM module using these commands:
ATE0 - For echo off
AT+CNMI=2,2,0,0,0 <ENTER> - Auto opened message Receiving. (No need to open
message)
ATD<Mobile Number>; <ENTER> - making a call (ATD+919610126059;\r\n)
AT+CMGF=1 <ENTER> - Selecting Text mode
AT+CMGS=”Mobile Number” <ENTER> - Assigning recipient’s mobile number
>>Now we can write our message
>>After writing message
Ctrl+Z send message command (26 in decimal).
ENTER=0x0d in HEX
The SIM900 is a complete Quad-band GSM/GPRS Module which delivers GSM/GPRS
850/900/1800/1900MHz performance for voice, SMS and Data with low power
consumption.
Circuit Description
Connections of this GSM based home automation circuit are quite simple, here a liquid
crystal display is used for displaying status of home appliances which is directly connected
to arduino in 4-bit mode. Data pins of LCD namely RS, EN, D4, D5, D6, D7 are connected
to arduino digital pin number 6, 7, 8, 9, 10, 11. And Rx and Tx pin of GSM module is directly
connected at Tx and Rx pin of Arduino respectively. And GSM module is powered by using
a 12 volt adaptor. 5 volt SPDT 3 relays are used for controlling LIGHT, FAN and TV. And
relays are connected to arduino pin number 3, 4 and 5 through relay driver ULN2003 for
controlling LIGHT, FAN and TV respectively.
Code Description
In programming part of this project, first of all in programming we includes library for liquid
crystal display and then we defines data and control pins for LCD and home appliances.
#include<LiquidCrystal.h>
LiquidCrystal lcd(6,7,8,9,10,11);
#define Fan 3
#define Light 4
#define TV 5
int temp=0,i=0;
int led=13;
After this serial communication is initialized at 9600 bps and gives direction to used pin.
void setup()
lcd.begin(16,2);
Serial.begin(9600);
pinMode(led, OUTPUT);
pinMode(Fan, OUTPUT);
pinMode(Light, OUTPUT);
pinMode(TV, OUTPUT);
For receiving data serially we have used two functions one is Serial.available which
checks whether any serial data is coming and other one is Serial.read which reads the data
that comes serially.
while (Serial.available())
char inChar=Serial.read();
After receiving data serially we have stored it in a string and then waiting for Enter.
void serialEvent()
while(Serial.available())
if(Serial.find("#A."))
digitalWrite(led, HIGH);
delay(1000);
digitalWrite(led, LOW);
while (Serial.available())
char inChar=Serial.read();
str[i++]=inChar;
if(inChar=='*')
temp=1;
return;
When Enter comes program start to compare received string with already defined string
and if string matched then a relative operation is performed by using appropriate command
that are given in code.
void check()
if(!(strncmp(str,"tv on",5)))
digitalWrite(TV, HIGH);
lcd.setCursor(13,1);
lcd.print("ON ");
delay(200);
digitalWrite(TV, LOW);
lcd.setCursor(13,1);
lcd.print("OFF ");
delay(200);
#include<LiquidCrystal.h>
LiquidCrystal lcd(6,7,8,9,10,11);
#define Fan 3
#define Light 4
#define TV 5
int temp=0,i=0;
int led=13;
char str[15];
void setup()
{
lcd.begin(16,2);
Serial.begin(9600);
pinMode(led, OUTPUT);
pinMode(Fan, OUTPUT);
pinMode(Light, OUTPUT);
pinMode(TV, OUTPUT);
lcd.setCursor(0,0);
lcd.print("GSM Control Home");
lcd.setCursor(0,1);
lcd.print(" Automaton ");
delay(2000);
lcd.clear();
lcd.print("Circuit Digest");
delay(1000);
lcd.setCursor(0,1);
lcd.print("System Ready");
Serial.println("AT+CNMI=2,2,0,0,0");
delay(500);
Serial.println("AT+CMGF=1");
delay(1000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Fan Light TV ");
lcd.setCursor(0,1);
lcd.print("OFF OFF OFF ");
}
void loop()
{
lcd.setCursor(0,0);
lcd.print("Fan Light TV");
if(temp==1)
{
check();
temp=0;
i=0;
delay(1000);
}
}
void serialEvent()
{
while(Serial.available())
{
if(Serial.find("#A."))
{
digitalWrite(led, HIGH);
delay(1000);
digitalWrite(led, LOW);
while (Serial.available())
{
char inChar=Serial.read();
str[i++]=inChar;
if(inChar=='*')
{
temp=1;
return;
}
}
}
}
}
void check()
{
if(!(strncmp(str,"tv on",5)))
{
digitalWrite(TV, HIGH);
lcd.setCursor(13,1);
lcd.print("ON ");
delay(200);
}
else if(!(strncmp(str,"tv off",6)))
{
digitalWrite(TV, LOW);
lcd.setCursor(13,1);
lcd.print("OFF ");
delay(200);
}
All batteries have certain voltage limit to discharge, if it goes beyond the prescribed limit, the life
span of the battery will reduce drastically.
Being electronics enthusiasts, we all might have a battery for testing our prototype circuits. Since
we concentrate on the prototype during experiment, we care less on the battery.
The proposed circuit will show you how much energy left in the battery, this circuit may be
connected to battery, while you prototyping your circuits. When this circuit indicates low battery,
you may put the battery to charge. The circuit has 6 LEDs, one LED glow at a time to indicate the
voltage level of the battery.
If your battery is full, the left most LED glows and you battery is dead or about to die, the right
most LED glows.
The circuit consists of Arduino which is the brain of the system, a potential divider which helps
the Arduino to sample the input voltage. A pre-set resistor is used to calibrate the above setup.
The series of 6 LEDs will indicate the battery level.
LED5 – 20% to 5%
The Arduino measures a narrow range of voltage from 12.70V to 11.90V. A fully charged battery
should have voltage above 12.70V after disconnecting from charger. A low battery voltage must
not go below 11.90V for a 12V sealed lead-acid battery.
Author’s prototype:
Program:
int analogInput = 0;
int f=2;
int e=3;
int d=4;
int c=5;
int b=6;
int a=7;
int s=13;
float vout = 0.0;
float vin = 0.0;
float R1 = 100000;
float R2 = 10000;
int value = 0;
void setup()
{
Serial.begin(9600);
pinMode(analogInput,INPUT);
pinMode(s,OUTPUT);
pinMode(a,OUTPUT);
pinMode(b,OUTPUT);
pinMode(c,OUTPUT);
pinMode(d,OUTPUT);
pinMode(e,OUTPUT);
pinMode(f,OUTPUT);
digitalWrite(s,LOW);
digitalWrite(a,HIGH);
delay(500);
digitalWrite(b,HIGH);
delay(500);
digitalWrite(c,HIGH);
delay(500);
digitalWrite(d,HIGH);
delay(500);
digitalWrite(e,HIGH);
delay(500);
digitalWrite(f,HIGH);
delay(500);
digitalWrite(a,LOW);
digitalWrite(b,LOW);
digitalWrite(c,LOW);
digitalWrite(d,LOW);
digitalWrite(e,LOW);
digitalWrite(f,LOW);
}
void loop()
{
value = analogRead(analogInput);
vout = (value * 5.0) / 1024;
vin = vout / (R2/(R1+R2));
Serial.println("Input Voltage = ");
Serial.println(vin);
if(vin>12.46) {digitalWrite(a,HIGH);}
else { digitalWrite(a,LOW);}
if(vin<=12.46 && vin>12.28) {digitalWrite(b,HIGH);}
else { digitalWrite(b,LOW);}
if(vin<=12.28 && vin>12.12) {digitalWrite(c,HIGH);}
else { digitalWrite(c,LOW);}
if(vin<=12.12 && vin>11.98) {digitalWrite(d,HIGH);}
else { digitalWrite(d,LOW);}
if(vin<=11.98 && vin>11.90){digitalWrite(e,HIGH);}
else {digitalWrite(e,LOW);}
if(vin<=11.90) {digitalWrite(f,HIGH);}
else {digitalWrite(f,LOW);}
delay(2000);
}
//--------Program developed by R.Girish---------//
The calibration for this Arduino 6 LED battery level indicator circuit must be done carefully, if you
did not calibrate correctly, the circuit will show incorrect voltage level of the battery.
When you turn on the circuit, it starts with LED test, where the LEDs glow up sequentially with
some delay. This might help you to debug errors while arranging the LEDs.
3) Rotate the preset resistor clock wise or counter clock wise and bring the readings to 12.50V.
4) Now, reduce the variable power supply to 12.00V, the readings on the serial monitor should
show the same or very close to 12.00V
5) Now, increase the voltage to 13.00V, the readings on serial monitor should also show the
same or very close.
6) At the same time when you increase or decrease the voltage, the each LED should turn
on/off with different voltage levels.
Once the above steps are done successfully, your battery level indicator circuit will be ready to
serve the intended purpose.
Arduino SPWM Generator Circuit
In this post we learn how to generate sine wave pulse-width-modulation or SPWM through Arduino,
which can be used for making a pure sine wave inverter circuit or similar gadgets.
The Arduino code is developed by me, and it is my first Arduino code, ...and it looks pretty good :)
What is SPWM
I have already explained how to generate SPWM using opamps in one of my earlier articles, you could
go through it for understanding how it can be created using discrete components and regarding its
importance.
Basically, SPWM which stands for sine wave pulse width modulation, is a type of pulse modulation
where the pulses are modulated to simulate a sinusoidal waveform, so that the modulation is able to
attain properties of a pure sine wave.
To implement a SPWM the pulses are modulated with an initial narrower widths which gradually get
broader at the center of the cycle, and finally end being narrower at the end to finish the cycle.
To be more precise, the pulses begin with narrowest widths which gradually get broader with each
subsequent pulses, and gets broadest at the center pulse, after this, the sequence continues on but with
an opposite modulation, that is the pulses now gradually begin getting narrower until the cycle finishes.
This constitutes one SPWM cycle, and this repeats throughout at a particular rate as determined by the
application frequency (usually 50Hz or 60Hz). Typically, SPWM is used for driving power devices such as
mosfets or BJTs in inverters or converters.
This special modulation pattern ensures that the frequency cycles are executed with a gradually
changing average voltage value (also called the RMS value) , instead of throwing sudden Hi/low voltage
spikes as normally witnessed in flat square wave cycles.
This gradually modifying PWMs in a SPWM is purposely enforced so that it closely replicates the
exponentially rising/falling pattern of a standard sinewaves or sinusoidal waveform, hence the name
sinewave PWM or SPWM.
The above explained SPWM can be easily implemented using a few discrete parts, and also using
Arduino which will probably enable you to get more accuracy with the waveform periods.
The following Arduino code can be used for implementing the intended SPWM for a given application.
Gosh!! that looks awfully big, if you know how to shorten it, you may certainly feel free to do it at your
end.
void setup(){
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
void loop(){
digitalWrite(8, HIGH);
delayMicroseconds(500);
digitalWrite(8, LOW);
delayMicroseconds(500);
digitalWrite(8, HIGH);
delayMicroseconds(750);
digitalWrite(8, LOW);
delayMicroseconds(500);
digitalWrite(8, HIGH);
delayMicroseconds(1250);
digitalWrite(8, LOW);
delayMicroseconds(500);
digitalWrite(8, HIGH);
delayMicroseconds(2000);
digitalWrite(8, LOW);
delayMicroseconds(500);
digitalWrite(8, HIGH);
delayMicroseconds(1250);
digitalWrite(8, LOW);
delayMicroseconds(500);
digitalWrite(8, HIGH);
delayMicroseconds(750);
digitalWrite(8, LOW);
delayMicroseconds(500);
digitalWrite(8, HIGH);
delayMicroseconds(500);
digitalWrite(8, LOW);
//......
digitalWrite(9, HIGH);
delayMicroseconds(500);
digitalWrite(9, LOW);
delayMicroseconds(500);
digitalWrite(9, HIGH);
delayMicroseconds(750);
digitalWrite(9, LOW);
delayMicroseconds(500);
digitalWrite(9, HIGH);
delayMicroseconds(1250);
digitalWrite(9, LOW);
delayMicroseconds(500);
digitalWrite(9, HIGH);
delayMicroseconds(2000);
digitalWrite(9, LOW);
delayMicroseconds(500);
digitalWrite(9, HIGH);
delayMicroseconds(1250);
digitalWrite(9, LOW);
delayMicroseconds(500);
digitalWrite(9, HIGH);
delayMicroseconds(750);
digitalWrite(9, LOW);
delayMicroseconds(500);
digitalWrite(9, HIGH);
delayMicroseconds(500);
digitalWrite(9, LOW);
//-------------------------------------//
In the next post I'll explain how to use the above Arduino based SPWM generator to make a pure
sinewave inverter circuit....keep reading!
In the last article we learned how to generate sine wave pulse width modulation or SPWM though
Arduino, we are going to use the same Arduino board to make the proposed simple pure sine wave
inverter circuit.
You just have to program the arduino board with the SPWM code as explained in the previous article,
and hook it up with some of the external devices.
Pin#8 and pin#9 generate the SPWMs alternately and switch the relevant mosfets with the same
SPWM pattern.
The mosfst in turn induce the transformer with high current SPWM waveform using the battery
power, causing the secondary of the trafo to generate an identical waveform but at the mains AC
level.
The proposed Arduino SPWM inverter circuit could be upgraded to any preferred higher wattage
level, simply by upgrading the mosfets and the trafo rating accordingly.
In the diagram the Arduino board could be seen supplied from a 7812 IC circuit, this could be
built by wiring a standard 7812 IC in the following manner. The IC will ensure that the input to
the Arduino never exceeds the 12V mark, although this might not be absolutely critical, unless
the battery is rated over 18V.
If you have any questions regarding the above SPWM inverter circuit using a programmed
Arduino, please feel free to ask them through your valuable comments.