You are on page 1of 208

TRICKY CIRCUIT

PROJECTS WITH
PROGRAMMED LEVEL
HANDSON
Programmed Staircase Lights, IR Remote, Tune or
Sound Generator, Movement Detector, Vehicle
Tracking, Line Follower Robot, Controlling
Brightness of LED etc...,

Anbazhagan K
Copyright © 2020 Anbazhagan K

All rights reserved

The characters and events portrayed in this book are fictitious. Any similarity to real persons, living
or dead, is coincidental and not intended by the author.

No part of this book may be reproduced, or stored in a retrieval system, or transmitted in any form or
by any means, electronic, mechanical, photocopying, recording, or otherwise, without express written
permission of the publisher.
CONTENTS

Title Page
Copyright
Acknowledgments
Introduction
1. PDA Charger Circuit
2. Programmed Staircase Lights utilizing PIR Sensor along with Relay
3. IR Remote Tester Circuit
4. Tune or Sound Generator Circuit
5. PIR Sensor Based Motion Detector/Sensor Circuit
6. Water Level Indicator Alarm
7. Interfacing HC-05 Bluetooth Module with MSP430 Launchpad to control
a LED
8. Movement Detector Using MSP430 Launchpad and PIR Sensor
9. Vehicle Tracking and Accident Alert System utilizing MSP430
Launchpad and GPS Module
10. Line Follower Robot Using MSP430 LaunchPad
11. I2C correspondence with MSP430 Launchpad
12. Sending Email Using MSP430 Launchpad and ESP8266
13. RFID Interfacing with MSP430 Launchpad
14. Interfacing RTC module (DS3231) with MSP430: Digital Clock
15. Interfacing Stepper Motor with MSP430G2
16. Beginning with MSP430 utilizing Code Composer Studio-Blinking a
LED
17. Interfacing Servo Motor with MSP430G2
18. Heartbeat width Modulation (PWM) utilizing MSP430G2: Controlling
Brightness of LED
19. Step by step instructions to utilize ADC in MSP430G2 - Measuring
Analog Voltage
20. Interfacing LCD with MSP430G2 LaunchPad
Thank you
ACKNOWLEDGMENTS

The writer might want to recognize the diligent work of the article group in
assembling this book. He might likewise want to recognize the diligent
work of the Raspberry Pi Foundation and the Arduino bunch for assembling
items and networks that help to make the Internet of Things increasingly
open to the overall population. Yahoo for the democratization of
innovation!
INTRODUCTION

The Internet of Things (IOT) is a perplexing idea comprised of numerous


PCs and numerous correspondence ways. Some IOT gadgets are associated
with the Internet and some are most certainly not. Some IOT gadgets
structure swarms that convey among themselves. Some are intended for a
solitary reason, while some are increasingly universally useful PCs. This
book is intended to demonstrate to you the IOT from the back to front. By
structure IOT gadgets, the per user will comprehend the essential ideas and
will almost certainly develop utilizing the rudiments to make his or her very
own IOT applications. These included ventures will tell the per user the best
way to assemble their very own IOT ventures and to develop the models
appeared. The significance of Computer Security in IOT gadgets is
additionally talked about and different systems for protecting the IOT from
unapproved clients or programmers. The most significant takeaway from
this book is in structure the tasks yourself.
1. PDA CHARGER
CIRCUIT
Cell phones by and large accuse of 5v controlled DC supply, so essentially
we are going to manufacture a 5v directed DC supply from 220 AC. This
DC supply is used to charge mobiles just as the force hotspot for
computerized circuits, breadboard circuits, ICs, microcontrollers and so
forth.
You can likewise assemble 6V DC, 9V, 12V, 15V and so forth by utilizing
legitimate transformer, capacitor and voltage controller. The fundamental
idea continues as before, you need to mastermind a warmth sink for higher
voltage and current.
This circuit principally comprises a stage down Transformer, a Full wave
connect rectifier and a 5V voltage controller IC (7805). We can separate
this circuit into 4 sections: (1) Step down AC voltage (2) Rectification (3)
Filtration (4) Voltage Regulation.
1. Venture down AC voltage
As we are changing over 220V AC into a 5V DC, first we need a stage
down transformer to lessen such high voltage. We have utilized 9-0-9 1A
step-down transformer, which convert 220V AC to 9V AC. In transformer
there are essential and auxiliary loops which venture up otherwise step
down the voltage as indicated by the no of turn in the curls.
Determination of legitimate transformer is significant. Current rating relies
on the Current necessity of Load (circuit which will utilize the produce
DC). The voltage rating ought to be more than the necessary voltage.
Means in case we need 5V DC, transformer ought to in any event have a
rating of 7V, in light of the fact that voltage controller IC 7805 at any rate
need 2V more for example 7V to give a 5V voltage.

2. Amendment

Amendment is the way bring closer expelling the negative piece of the
Alternate Current (AC), thus creating the fractional DC. This can be
accomplished by utilizing 4 diodes. Diodes just permit current to stream
one way. In first half pattern of AC diode D2 along with D3 are forward
one-sided and D1 along with D4 are turned around one-sided, and in the
subsequent half cycle (negative half) Diode D1 along with D4 are forward
one-sided and D2 along with D3 are switched one-sided. This Combination
changes over the negative half cycle into positive.
A full wave connect rectifier segment is accessible in the market, which
comprise that mix of 4 diode inside. Here we have utilized this segment.

3. Filtration

The yield after the Rectification is definitely not a legitimate DC, it is


swaying yield and has an exceptionally high wave factor. We needn't bother
with that throbbing yield, for this we use Capacitor. Capacitor charge till the
waveform goes to its pinnacle and release into Load circuit when waveform
goes low. So when yield is going low, capacitor keeps up the make the most
voltage supply into the Load circuit, henceforth making the DC. Presently
how the evaluated of this channel capacitor must be determined. Here is the
formulae:
C = I * t/V
C= capacitance to be determined
I= Max yield current (suppose 500mA)
t= 10ms,
We will get wave of 100Hz recurrence in the wake of changing over 50Hz
Alternating Current into Direct Current, through full wave connect rectifier.
As the negative piece of the beat is changed over into positive, one
heartbeat will be tallied two. So the time frame will be 1/100= .01 Second=
10ms
V = Peak voltage – voltage given to voltage controller IC (+2 more than
appraised implies 5+2=7)
9-0-9 is the RMS evaluation of changes so top voltage is Vrms * 1.414= 9*
1.414= 12.73v
Presently 1.4v will be dropped on 2 diodes (0.7 per diode) as 2 will be
forward one-sided for half wave.
So 12.73 – 1.4 = 11.33v
At the point when capacitor releases into load circuit, it must give 7v to
7805 IC to work so at long last V is:
V = 11.33 – 7= 4.33v
So now C = I * t/V
C = 500mA * 10ms/4.33 = .5 * .01/4.33 = 1154uF ~ 1000uF

4. Voltage Regulation

A voltage controller IC 7805 is utilized to give a managed 5v DC. Info


voltage ought to be 2volts more than the evaluated yield voltage for
appropriate working of IC, implies at any rate 7v is required, in case it can
work in input voltage scope of 7-20V. Voltage controllers have all the
hardware inside it to give an appropriate managed DC. Capacitor of 0.01uF
ought to be associated with the produce of the 7805 to take out the clamor,
delivered by transient changes in voltage.
Here is the finished circuit graph for PDA charger circuit:

You must be highly cautious while building this circuit, as AC mains 220V
is included here.
2. PROGRAMMED
STAIRCASE LIGHTS
UTILIZING PIR SENSOR
ALONG WITH RELAY
This programmed flight of stairs light circuit switch on the flight of stairs
lights consequently when somebody enters on the steps and gets off after
few time. There are 2 significant parts in this circuit, 1st is PIR Sensor
(Passive Infrared Sensor) along with 2nd is Relay.

PIR Sensor

PIR sensor is utilized here to identify the Human body development, at


whatever point there is anyone development the voltage at yield pin
changes. Essentially it recognizes the Change in Heat, and produce yield at
whatever point such location happens. You can become familiar with PIR
sensor here, there are some valuable highlights in PIR sensor like how to
change the separation extend, how to set the length for which the light must
be ON and so on.
Additionally check: Automatic Staircase light utilizing AVR
Microcontroller

Hand-off

Hand-off is an electromagnetic switch, which is constrained by little


current, and used to turn ON and OFF moderately a lot bigger current.
Means by applying little current we can turn ON the hand-off which permit
a lot bigger current to stream. Transfer is the genuine case of managing the
AC (interchange current) gadgets, utilizing an a lot littler DC current.
Normally utilized Relay is Single Pole Double Throw Relay, it has five
terminals as beneath:

When there is no voltage applied to the loop, COM (normal) is associated


with NC (regularly shut contact). When there is some voltage given to the
loop, the electromagnetic field created. Which draw in the Dynamo (switch
associated with spring), and COM and NO (ordinarily open contact) gets
associated, which permit bigger current to stream. Transfers are accessible
in numerous appraisals, here we utilized 6V working voltage hand-off,
which permit 7A-250VAC current to stream.
Hand-off is designed by utilizing a little Driver circuit which comprise a
Transistor, Diode along with a resistor. Transistor is utilized to enhance the
current with the goal that full current (from the DC source – 9v battery) can
course through curl to completely energies it. Resistor is utilized to give
biasing to transistor. Also, Diode is utilized to forestall invert current
stream, when the transistor is turned OFF. Each Inductor curl produces
equivalent and inverse EMF when turned OFF out of nowhere, this may
make changeless harm parts, so Diode must be utilized to forestall invert
current. A Relay module is effectively accessible in the market with all its
Driver circuit on the board or you can make it by utilizing above parts. Here
we have utilized 6V Relay module.

Circuit Explanation
This programmed flight of stairs light circuit can be handily clarified. At
whatever point PIR sensor distinguishes anyone development, its OUTPUT
pin turns out to be HIGH, which applies the activating voltage to the base of
the transistor, transistor jump ON, and current began coursing through the
loop. Loop in Relay gets energies and make electromagnetic field, which
draws in the switch and COM and NO get associated. This permits an a lot
bigger current (220v AC) to stream, which turns ON the BULB. You can
increment or reduction the Bulb ON term by setting up PIR sensor.
3. IR REMOTE TESTER
CIRCUIT
We are particularly acquainted with our TVs, DVDs, MP3 players, music
frameworks along with many other gadget that are constrained by utilizing
IR Remote. There are numerous sorts of remote controls accessible for
various gadgets however a big part of them take a shot at around 38KHz
Frequency signal. In some cases we face a normal problem identified with
IR TV or other gadget remote control that in the event that it is working or
not. We check on various occasions to discover if the remote is functioning
or not. We are gonna to do an IR Remote analyzer circuit utilizing
TSOP1738 IR Receiver sensor circuit. This Thin small outline package
1738 sensor can detect 38Khz Frequency flag and can distinguish any IR
signal.

Parts Required

TSOP1738

LM7805 Voltage Regulator

1K resistor

150 ohm Resistor


1000uF capacitor

Jumper wires

Bread board

Nine Volt Battery

Battery Connector

Ringer

Driven

Television Remote

When TSOP1738 sensor gets IR heartbeats or sign its yield pin goes LOW
along with become HIGH once more when sign is lost. As a matter of
course yield pin stays in HIGH state. A TSOP1738 sensor is appeared in the
underneath picture.
Circuit Diagram and Explanation
As appeared in the above IR remote manage analyzer circuit, we have
associated a signal and a yellow LED for sign. LM7805 Voltage controller
is additionally included to the circuit for giving 5 volt voltage supply to the
circuit, and a 9 volt battery is used for driving the circuit. Pin number 1 of
LM7805 is associated with battery's Positive terminal and pin second is
associated with ground terminal of battery. Pin 2 of Thin small outline
package 1738 is straightforwardly combined with pin number 3 of LM7805
and first number is combined with ground. Ringer is associated with pin
number three of TSOP1738 trough a 1K opposition and yellow LED's
negative terminal is associated with a similar terminal trough 150 ohm
resistor.
In the wake of driving up the circuit when we press any catch of IR Remote
then remote sends some IR beats of around 38Khz recurrence. These
heartbeats are gotten by TSOP1738 sensor and as examined above, it gives
a LOW sign. We utilizes this LOW yield sign to initiate the bell and LED.
So by getting LOW yield sign of TSOP1738 Buzzer begins signaling and
LED begin shining, which demonstrates that the remote control is working
accurately. In the event that this IR remote analyzer circuit doesn't react
with the remote control's catch squeezes, it demonstrates that the remote
control isn't working appropriately. (Additionally check this TV remote
manage jammer circuit)
4. TUNE OR SOUND
GENERATOR CIRCUIT
A great deal of toys have a tune tones in them. Be that as it may, how do
these tones produce? Here we have planned a straightforward tone
generator circuit utilizing just a solitary tune generator IC.

Circuit Components

BT66T-19L

1K Resistor

Breadboard

3 Volt lithium Battery

Bell

Press Button

Circuit Diagram and Explanation


?Working and associations for this venture is simple. BT66T Melody
generator IC's BD or yield pin is associated with signal through a 1K
resistor and Vss to ground. A press button is combined with Vdd pin of tune
IC with battery. At the point when we press this appended button, song IC
plays a "For Elise" tune utilizing a signal. In case we continue squeezing the
catch, song rehash and once more.
In this circuit we have utilized just single chip specifically BT66T-19L for
age of Elise song or sound. A press button is utilized to begin song and a
signal for sound and a solitary 3 Volt Lithium battery for controlling the
circuit.
Fundamental part of this circuit is song generator chip which produce a tune
tone when we press button. There are a few highlights referenced for tune
generator family's IC with certain details.

BT66T has some song ICs to be specific:

BT66T-19L "For Elise" song Generation


BT66T-02L for "Jingle chime" tune Generation
BT66T-08L for "Cheerful Birthday" tune Generation
BT66T-19L for "Romantic tale" tune Generation
BT66T-19L for "It's a Small World" song Generation
Highlights:

Plays a song comprising of 64 note


Inbuilt RC oscillator
64-note ROM memory
TO-92 Package
Start from the head of song
Force on Reset
Direct piezo drive
Dynamic speaker taxi be driven utilizing transistor remotely.
Sound range 2 octaves
Working Voltage 1.3 Volt to 3.3 Volts
5. PIR SENSOR BASED
MOTION
DETECTOR/SENSOR
CIRCUIT
Uninvolved Infrared Sensor (PIR) is extremely helpful module, used to
manufacture numerous sorts of Security Alarm Systems and Motion
Detectors. It is called inactive in light in case it gets infrared, not emanates.
Fundamentally PIR sensor identifies any adjustment in heat, and at
whatever point it distinguishes any change, its yield PIN turns out to be
HIGH. They are likewise alluded as Pyroelectric or IR movement sensors.
Here we should take note of that each item emanates some measure of
infrared when warmed. Human likewise produces infrared on account of
body heat. PIR sensors can identify modest quantity of variety in infrared.
At whatever point an item goes through the sensor go, it produces infrared
on account of the erosion among air and object, and get captured by PIR.
The fundamental segment of PIR sensor is Pyroelectric sensor appeared in
figure (rectangular gem behind the plastic top). Alongside this, BISS0001
("Micro Power PIR Motion Detector IC"), a few resistors, capacitors and
different segments used to fabricate PIR sensor. BISS0001 IC take the
contribution from sensor and does handling to make the yield pin HIGH or
LOW appropriately.
Pyroelectric sensor partition in two parts, when there is no movement, the
two parts stay in same state, implies the two detects a similar degree of
infrared. When someone enters in first a large portion of, the infrared
degree of one half gets more noteworthy than other, and this causes PIRs to
respond and makes the yield pin high.
Pyroelectric sensor is secured by a plastic top, which has cluster of
numerous Fresnel Lens inside. These focal points are bended in such a way
in this way, that sensor can cover a large number.
We have constructed a straightforward Motion finder circuit here. We are
utilizing a HC-SR501 PIR Sensor, a Light Emitting Diode (which will shine
at whatever point there is a movement infront of the sensor) along with
resistor. Vcc PIN of PIRs associated with the +ve terminal of the 9v battery,
GND pin is associated with -ve terminal of battery and Output pin of PIR is
associated with LED with a resistor of 220 Ohm. When there is any
movement in the scope of PIRs, LED will begin squinting.

Circuit Components

PIR Sensor (we utilized HC-SR501)

Resistor 220ohm (any resistor underneath 1k ohm)

Driven
Battery (5-9V)

Circuit Diagram and Explanation

PIRs sets aside some effort to stable itself as indicated by encompassing


conditions, so you can discover, LED turn ON and OFF arbitrarily for
around 10-60 seconds.
Presently when we discover the LED squinting at whatever point there is
any movement, think back of the PIR, you will discover a jumper which is
set between external corner PIN and center PIN (see chart above). This is
classified "non-retriggering" Or "Non-repeatable trigger" and jumper said to
be in L position. In this position LED will squint consistently until there is
movement.
Presently in the event that you interface this jumper between internal corner
PIN and center PIN, at that point LED will remain on constantly till there is
any movement. This 1 is classified "retriggering" or "Repeatable trigger"
along with jumper said to be in H position.
There are two potentiometers (appeared in above figure), used to set the
time postponement and separation extend. Time delay is the term where the
Light Emitting Diode will stay ON (out pin HIGH). In Non repeatable
activating, OUTPUT will turn out to be low naturally after the time delay.
In Repeatable activating OUTPUT will likewise turn out to be low after
time delay, yet in the event that there is a persistent human action;
OUTPUT will stay HIGH considerably after the time delay.
Turn the Distance Adjustment potentiometer clockwise pivot, expanded
detecting separation (around 7 meters), then again, the detecting separation
diminishes (around 3 meters).
Turn the Time postpone potentiometer clockwise pivot sensor the defer
extended (600S, 10 minutes), on the contrary side, abbreviate the deferral
(0.3 second).
By and large PIR recognizes infrared of 8 to 14 micrometer of frequency
and has scope of 3-15 meters with a field of view under 180 degrees. This
range can fluctuate upon various models. Some roof PIRs can cover 360
degrees. PIRs by and large work at 3-9V DC.
6. WATER LEVEL
INDICATOR ALARM
Water tank flood is a typical issue which prompts the wastage of water. In
case there are numerous answers for it like ball valves which naturally stop
the water stream once the tank gets full. In any case, being a hardware
excited wouldn't you like an electronic answer for it? So here is a
straightforward and helpful DIY that will control you to do a circuit which
will distinguish the water level along with will increase an alert after obtain
the water tank full otherwise a preset level.
This basic transistor based water level pointer circuit is valuable to display
the water levels in a tank. At whatever point tank gets replenishing, we get
alarms on specific levels. Here we have made 4 levels (low, medium, high
and full), we can make cautions for additional levels. We have added 3
LEDs to demonstrate introductory three levels (A, B, C), and one Buzzer to
show FULL level (D). At the point when tanks gets replenishing totally we
get signal sound from Buzzer.

Circuit Components

4 - BC547 transistors
6 - 220 ohm resistors

3 - Color LEDs - red, green, and yellow

1 – Buzzer

5 - 9v battery + battery cut

Breadboard

Circuit Diagram
We can think about this entire circuit as 4 little circuits, every one for
demonstrating/disturbing, when a specific level (A,B,C,D) of water have
been reached.
At the point when water level compasses to point A, circuit with RED LED
and transistor Q1 gets finished and RED LED gleams. Correspondingly
when water level compasses to point B, circuit with YELLOW LED and
transistor Q2 gets finished and Yellow LED sparkles, same goes with point
C. Lastly when tank gets full (Point D), circuit with bell gets finished and
ringer begins blaring.
Working
Here we are utilizing transistor (of NPN type) as a Switch. At first there is
no voltage given to the base of the Transistor Q1 along with the transistor is
in OFF state along with no current is coursing through gatherer and
producer along with Light Emitting Diode is OFF (See beneath chart to
comprehend Transistor Pin structure).

At the point when the water level scopes to Point An in the tank, the +ve
side of the battery gets associated with the base of the Transistor Q1 across
the water. So when a +ve voltage has been given to the base of the
Transistor Q1, it gets into ON state and current beginnings spilling out of
authority to producer. Also, RED LED gleams.
You can view resistors (R1, R2, R3) at the base of every transistor, which is
utilized to constrain the most extreme Base current. For the most part a
transistor gets its ON state completely when a voltage of 0.7 V is given to
the base. There are likewise resistors (R4, R5, R6) with every one of the
LEDs, to drop the voltage across LEDs, in any case LED may explode.
Same marvel occurs when water level ranges to Point B. When water level
scopes to Point B, a positive voltage gets applied to the Transistor Q2, it
kicks ON and momentum off moving through YELLOW LED, and LED
gleams. With same standard, GREEN LED shine when water level
compasses to Point C.And at long last Buzzer signals when water level
scopes to D.
Note that Left most wire in the tank must be lengthier than other four wires
in the tanks, since this is the wire which is associated with positive voltage.
7. INTERFACING HC-05
BLUETOOTH MODULE
WITH MSP430
LAUNCHPAD TO
CONTROL A LED
While a ton of remote advancements have been presented in past decade,
yet Bluetooth is as yet the most well known tech for short range remote
correspondence. In implanted frameworks HC-05/06 is the most well
known Bluetooth Module. We recently utilized this Bluetooth module in
numerous undertakings to manage home machines, robots and so forth and
interfaced it with other microcontroller:

Interfacing Bluetooth HC-05 with STM32F103C8 Blue Pill:


Managing Light Emitting Diode

Bluetooth Module Interfacing with ESP8266: Controlling a LED

Interfacing HC-05 Bluetooth module with AVR Microcontroller

Voice Controlled LEDs utilizing Arduino and Bluetooth


Today we will figure out how to interface Bluetooth module HC-05 with
MSP430 Launchpad from Texas Instruments. In this interfacing model, we
will control on-board Light Emitting Diode of MSP430 from the advanced
mobile phone by utilizing a Bluetooth Terminal android application.

In case you're new to MSP430, at that point you can begin with Getting
Started with MSP430G2 utilizing Energia IDE instructional exercise and
can follow all the MSP430 Tutorials here.

Materials Required

TI-MSP430 Launchpad

HC-05 Bluetooth module

Bluetooth Terminal App from Play Store

HC-05 Bluetooth Module

The HC-05 is a simple to utilize Bluetooth module. It utilizes sequential


correspondence convention (USART) to transmit among gadgets. There are
2 working modes for this module - first is Command mode and second is
Operating mode. The order mode is utilized for arranging the gadget
settings, similar to change secret word, baud rate and so on of module.
Working mode is utilized to send or get information between gadgets.

In this instructional exercise we'll be utilizing default settings (default secret


word is 0000 or 1234, gadget name is HC-05 and the default baud rate is
9600). Accordingly, we will just work in working mode.

The working voltage extend is 4V to 6V (regularly +5V) and working


current is 30 mA. The scope of the module is 100 meters. There are
complete 6 pins on the HC-05 Bluetooth module, out of which EN and
State pins are utilized in Command mode. The pin-out of HC-05 Bluetooth
module is demonstrated as follows:
Circuit Diagram

Circuit graph to interface HC-05 Bluetooth Module with TI-MSP340 Board


is demonstrated as follows.
Here, we have completed 4 associations from HC-05. The RxD and TxD
pins of HC-05 are associated with P1.1 and P1.2 of MSP430 separately for
sequential correspondence. What's more, Voltage Common Collector along
with GND of HC-05 are associated with Voltage Common Collector along
with GND of MSP430.

Programming MSP430 Launchpad for Bluetooth Module HC-05

The programming for this Bluetooth Controlled Light Emitting Diode


utilizing MSP430 is simple. MSP will be modified utilizing Energia IDE
which is fundamentally the same as Arduino IDE so the Arduino familiar
individuals won't face any trouble in getting this.
We initiate with characterizing a full scale for the red LED we are utilizing.
This line is only for straightforwardness, with the goal that we can utilize
LED instead of RED_LED
#define LED RED_LED

Next is our arrangement() work, Serial.begin() work is utilized to set the


baud rate for sequential correspondence to 9600 on the grounds that this is
the default baud rate for HC-05. We've additionally utilized the pinMode()
capacity to introduce the advanced pin as yield (which is LED for this
situation).

void setup() {

Serial.begin(9600);

pinMode(LED, OUTPUT);

In circle work, first we check if the information is accessible on sequential


port by Serial.available() work. Next characterize a variable data_recieved
which is putting away the estimation of Serial.read() work. This capacity is
utilized to get the information from bluetooth.

Next in if-else articulation we are checking the information sent from the
telephone. In the event that it is 1, at that point turn the LED on by utilizing
digitalWrite(LED, HIGH); and print message on the application that LED is
turned on by utilizing Serial.write() work. Furthermore, in case it is 2, at
that point turn the Light Emitting Diode off by utilizing digitalWrite(LED,
LOW); and print the message on the application that Light Emitting Diode
is OFF by utilizing Serial.write() work.

void loop() {

if (Serial.available())
{

char data_received;

data_received = Serial.read();

if (data_received == '1')

digitalWrite(LED, HIGH);

Serial.write("LED turned ON");

else if (data_received == '2')

digitalWrite(LED, LOW);

Serial.write("LED turned OFF");

Working of Bluetooth controlled LED utilizing MSP430

At last transfer the code into MSP430 utilizing Energia IDE, and download
and introduce the Bluetooth Terminal application on your advanced mobile
phone. The application will look like appearing underneath:
Presently turn on the Bluetooth in your advanced cell and interface with
Bluetooth module by choosing HC-06 from the rundown of accessible
gadgets. Utilize the secret phrase 0000 or 1234 to interface. After
association, a window will open titled with gadget name and associated
composed underneath it. This window will resemble the figure underneath:

In this window, have a go at sending 1 and 2 to MSP430 by means of


Bluetooth module HC-05. Sending 1 will turn on the LED and the message
will get imprinted on your telephone that "Drove turned ON" simply like
the figure underneath:
Also, sending 2 will kill the LED and the message will get imprinted on
your telephone that "Drove killed" simply like the figure underneath.
What's more, presto! You simply controlled a LED through your telephone
utilizing Bluetooth.

This is the manner by which a LED can be managed remotely utilizing


bluetooth. It tends to be effortlessly modified over into a Home
computerization venture by supplanting the LED with a Relay and any
home machine.
Code
#define LED RED_LED
void setup() {
Serial.begin(9600);
pinMode(2, OUTPUT);
}
void loop() {
if (Serial.available())
{
char data_received;
data_received = Serial.read();
if (data_received == '1')
{
digitalWrite(LED, HIGH);
Serial.write("LED turned ON\n");
}
if (data_received == '2')
{
digitalWrite(LED, LOW);
Serial.write("LED turned OFF\n");
}
}
}
8. MOVEMENT
DETECTOR USING
MSP430 LAUNCHPAD
AND PIR SENSOR
Movement discovery is a fundamental piece of security frameworks and
PIR sensor is mostly normally utilized sensor for trigging the alerts when
movement is identified. This sensor can distinguish human/creature
developments effectively by detecting the IR beams discharged by them.
We recently utilized PIR sensor to manufacture different sort of alerts and
security frameworks:

PIR Sensor along with Global System for Mobile Based Security
System

PIR Sensor Based Motion Detector/Sensor Circuit

Criminal Alarm Circuit

IOT based Raspberry Pi Home Security System with Email Alert

Today we will fabricate a similar sort of Motion identification alert by


interfacing a PIR sensor with TI-MSP430.

Materials Required
PIR Sensor Module

TI-MSP430 Launchpad

Driven

Ringer

Breadboard

Jumper wires

PIR Sensor Module

The PIR sensor represents Passive Infrared sensor which can identify
numerous degrees of radiations. As it is notable that each article discharges
some radiation and more sizzling materials produce a greater number of
radiations than different materials. That is the reason this sensor can
identify human/creature nearness since they are more sweltering than
different materials in encompassing. The module comprises a pyroelectric
sensor, which distinguishes the nearness of human/creature body. Also,
there is one Fresnel Lens appended to the sensor, which builds the scope of
the sensor. The pin-out for PIR sensor module is given underneath:
This module is customizable for example the affectability and time trigger
can be balanced by pivoting the handles of two potentiometers on the load
up.
There are 2 methods of working: Retriggering (H) mode and non-
Retriggering (I) mode.
In retriggering or H mode, the yield remains high as long as the movement
is happening. What's more, in non-retriggering or I mode, the yield remains
high at that point turns low after the trigger time and this procedure
proceeds insofar as movement is proceeded. Most applications use H mode
and we're likewise going to utilize this mode as it were. The PIR sensor
takes a shot at 5V to 12V force supply. Be that as it may, it can likewise be
fueled by 3.3V pins of the MSP430.
To get familiar with PIR sensor, follow the connection and furthermore
figure out how PIR sensor can be utilized with Arduino, Raspberry Pi along
with different microcontrollers for different applications:

Arduino Motion Detector utilizing PIR Sensor

Raspberry Pi Motion Sensor Alarm utilizing PIR Sensor

Interfacing PIR Sensor with PIC Microcontroller

IOT based Security System with Voice Message Using ESP8266


Interfacing PIR Sensor Module with TI-MSP430

Interfacing PIR Sensor with MSP430 is exceptionally simple. The Voltage


Common Collector along with GND pins of module is associated with
Voltage Common Collector along with GND pins of MSP430. The yield pin
of module is associated with eighth pin (P2.0) of MSP430. Albeit any pin
can be utilized yet you need to express the method of the pin as
information. The sixth pin (P1.4) is associated with LED and ringer.
Programming PIR Sensor Module for TI-MSP430

The code is straightforward. Here we are gonna to flicker the LED and
blare the ringer consistently when any movement gets identified by PIR
sensor.
In arrangement work, we announce that the pin 8 will be utilized as
information pin since it is bringing the yield from PIR module and the pin 6
will be utilized as a yield pin as it is associated with LED and bell.

void setup()

pinMode(8, INPUT);

pinMode(6, OUTPUT);

}
Next on the up and up work, right off the bat we check for the yield from
PIR module whether it is high or not. Presently in case the yield from PIR
module is high, at that point, it implies that some development is
recognized. So to demonstrate this, we turn the pin 6 low and high with a
period postponement of 100 milli seconds, so constant glimmering and
humming can be experienced.
void loop()

If(digitalRead(8) == HIGH)

digitalWrite(6, HIGH);

delay(100);

digitalWrite(6, LOW);

delay(100);

}
At last transfer the code to MSP430 utilizing Energia IDE and force the
board and sit tight for about a moment. The PIR sensor module sets aside
some effort to align. Following a moment, move your deliver front of
sensor, and it works. In the wake of evacuating your hand the blazing and
humming will stop. You can likewise have a go at changing the affectability
and time trigger utilizing the two potentiometers present on the PIR sensor.

Code
void setup()
{
pinMode(8, INPUT);
pinMode(6, OUTPUT);
}
void loop()
{
If(digitalRead(8) == HIGH)
{
digitalWrite(6, HIGH);
delay(100);
digitalWrite(6, LOW);
delay(100);
}
}
9. VEHICLE TRACKING
AND ACCIDENT ALERT
SYSTEM UTILIZING
MSP430 LAUNCHPAD
AND GPS MODULE
In past instructional exercises, we have found out about How to interface
GPS module with Computer and how to Track vehicle utilizing Global
System for Mobile along with Global Positioning System. We likewise
assembled Vehicle Accident Alert System utilizing Arduino and
accelerometer. We are again constructing a similar undertaking yet this time
a MSP430 launchpad and a vibration sensor will be utilized to identify
vehicle mishap. So this undertaking will likewise tell about interfacing a
vibration sensor with MSP430.
Here Vibration sensor module identifies the vibration of vehicle along with
imparts a sign to MSP430 Launchpad. At that point MSP430 brings
information from GPS module and send it to client Mobile Phone by means
of SMS utilizing GSM module. A LED will likewise shine as Accident
Alert sign, this LED can be supplanted by some caution. Area of the mishap
is sent as Google Map interface, got from the scope and longitude from the
GPS module.
Parts Required

MSP430 Launchpad

GSM Module

GPS Module

Vibration sensor module

16x2 LCD

Force Supply

Interfacing Wires
10 K-POT

Breadboard or PCB

Force supply 12v 1amp

3.3v Power supply

5v power supply

Prior to going into Project, we will talk about GPS, GSM and Vibration
Sensor. Likewise in case you are new to MSP430, at that point start with
LED flicker utilizing MSP430 Tutorial.

GPS Module and Its Working:

GPS represents Global Positioning System and used to identify the Latitude
along with Longitude of any area on the Earth, with precise UTC time
(Universal Time Coordinated). GPS module is utilized to follow the area of
mishap in our venture. This gadget gets the directions from the satellite for
every single second, with time along with date. We have recently removed
$GPGGA string in Vehicle Tracking System to discover the Latitude and
Longitude Coordinates.
GPS module transmits the data identified with following situation
continuously, and it sends such a significant number of information in
NMEA design (see the screen capture underneath). NMEA group comprises
a few sentences, wherein we just need one sentence. This sentence begins
from $GPGGA and contains the directions, time and other helpful data.
This GPGGA is alluded to Global Positioning System Fix Data. Find out
about NMEA sentences and perusing GPS information here.
We can separate arrange from $GPGGA string by including the commas in
the string. Assume you discover $GPGGA string and stores it in a cluster, at
that point Latitude can be found after two commas and Longitude can be
found after four commas. Presently, this scope and longitude can be placed
in different clusters.
The following is the $GPGGA String, alongside its depiction:

$GPGGA,104534.000,7791.0381,N,06727.4434,E,1,08,0.9,510.4,M,43.
9,M,,*47
$GPGGA,HHMMSS.SSS,latitude,N,longitude,E,FQ,NOS,HDP,altitude,
M,height,M,,checksum data

Identifier Description

$GPGGA Global Positioning system fix data

HHMMSS.S Time in hour minute seconds and milliseconds


SS format.

Latitude Latitude (Coordinate)

N Direction N=North, S=South

Longitude Longitude(Coordinate)

E Direction E= East, W=West

FQ Fix Quality Data

NOS No. of Satellites being Used

HDP Horizontal Dilution of Precision

Altitude Altitude (meters above from sea level)

M Meter

Height Height

Checksum Checksum Data


GSM Module

The SIM900 is a finished Quad-band GSM/GPRS Module which can be


installed handily utilized by client otherwise specialist. SIM900 Global
System for Mobile Module gives an industry-standard interface. SIM900
conveys Global System for Mobile/General Packet Radio Service
850/900/1800/1900MHz execution for voice, Short Message Service, Data
with low force utilization. It is effectively accessible in the shop.

SIM900 planned by utilizing single-chip processor incorporating


AMR926EJ-S center

Quad-band Global System for Mobile/General Packet Radio


Service module in little size.

General Packet Radio Service Enabled

AT Commands
AT implies ATTENTION. This order is utilized to control the GSM module.
There are a few orders for calling and informing that we have utilized in a
significant number of our past GSM ventures with Arduino. For testing
GSM Module we utilized AT order. In the wake of accepting AT Command
GSM Module react with OK. It implies GSM module is working fine. The
following is some AT orders we utilized here in this task:
ATE0 For reverberation off
AT+CNMI=2,2,0,0,0 <ENTER> Auto opened message Receiving. (No
compelling reason 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 beneficiary's portable
number
>>Now we can compose our message
>>After composing a message
Ctrl+Z sends message order (26 in decimal).
ENTER=0x0d in HEX
(To get familiar with GSM module, Check our different GSM ventures with
different microcontrollers here)

Vibration Sensor Module

In this MSP430 Accident Alert System venture, we have utilized a vibration


sensor module which recognizes vibrations or unexpected regulations.
Vibration sensor module gives a computerized yield HIGH/LOW rationale
relying upon the module. For our position, we have utilized a functioning
HIGH rationale vibration sensor module. It implies at whatever point the
vibration sensor will identify vibration it will give HIGH rationale to the
microcontroller.
Schematic Explanation

Circuit Connections of this Vehicle Accident Alert System Project is basic.


Here Tx pin of Global Positioning System module is legitimately associated
with computerized pin number P1_1 of MSP430 Launchpad (equipment
Serial) and 5v is utilized to control GPS Module. By utilizing Software
Serial Library here, we have permitted sequential correspondence on pin
P_6 and P1_7, and made them Rx and Tx separately and associated with the
GSM module. 12 Volt supply is utilized to control the GSM Module. The
vibration sensor is associated at P1_3. A LED is additionally utilized for
show the mishap location. Rest of associations are appeared in the circuit
graph.
Programming Explanation

Programming for this venture is simple aside from the GPS part. Complete
code is given toward the finish of the undertaking. To compose or arrange
the code in MSP430 we have utilized Energia IDE which is Arduino good.
A large portion of Arduino IDE capacity can be used straightforwardly in
this Energia IDE.
So above all else we have incorporated a necessary libraries and proclaimed
pin and factors.

#include <SoftwareSerial.h>

SoftwareSerial GSM(P1_6, P1_7); // RX, TX


float latitude=0;

float logitude=0;

#define led P1_0

const int vibrationSensor=PUSH2;

int i=0;

Given capacity is utilized for perusing vibration sensor signal. This capacity
will channel little or bogus vibrations also.

#define count_max 25

char SensorRead(int pin) // read sw with debounce

char count_low=0,count_high = 0;

do

delay(1);

if (digitalRead(pin) == HIGH)

count_high++;

count_low = 0;
}

else

count_high = 0;

count_low++;

}while(count_low< count_max && count_high < count_max);

if (count_low >= count_max)

return LOW;

else

return HIGH;

Underneath work recognizes vibration and call gpsEvent() capacity to get


GPS facilitate lastly call the Send() capacity to send SMS.

void loop()

if(SensorRead(vibrationSensor) == HIGH)

{
digitalWrite(led, HIGH);

gpsEvent();

Send();

digitalWrite(led, LOW);

delay(2000);

Given Function is liable for getting GPS strings from GPS module, remove
the directions from them and convert them in degree-decimal organization.

void gpsEvent()

char gpsString[55];

char test[]="RMC";

i=0;

while(1)

while (Serial.available()) //Serial incomming data from GPS

{
char inChar = (char)Serial.read();

gpsString[i]=inChar; //store incomming data from


GPS to temparary string str[]

i++;

if (i < 4)

if(gpsString[i-1] != test[i-1]) //check for right string

i=0;

int degree=0;

degree=gpsString[16]-48;

degree*=10;

degree+=gpsString[17]-48;

int minut_int=0;

minut_int=gpsString[18]-48;

minut_int*=10;

minut_int+=gpsString[19]-48;

int minut_dec=0;
minut_dec+= (gpsString[21]-48)*10000;

minut_dec+= (gpsString[22]-48)*1000;

minut_dec+= (gpsString[23]-48)*100;

minut_dec+= (gpsString[24]-48)*10;

minut_dec+= (gpsString[25]-48);

float minut= ((float)minut_int +


((float)minut_dec/100000.0))/60.0;

latitude= ((float)degree + minut);

Lastly, Send() work is utilized to send the Short Message Service to the
client number that is embedded in this piece of the code.

void Send()

GSM.print("AT+CMGS=");

GSM.print('"');

GSM.print("961****059"); // enter your Mobile number

GSM.println('"');

delay(500);

// GSM.print("Latitude:");

// GSM.println(latitude);
GSM.println("Accident Happned");

delay(500);

// GSM.print(" longitude:");

// GSM.println(logitude);

GSM.println("Click On link to see Location");

GSM.print("http://maps.google.com/maps?
&z=15&mrt=yp&t=k&q=");

GSM.print(latitude,6);

GSM.print("+");

GSM.print(logitude,6);

GSM.write(26);

delay(4000);

Code
#include <SoftwareSerial.h>
SoftwareSerial GSM(P1_6, P1_7); // RX, TX
float latitude=0;
float logitude=0;
#define led P1_0
const int vibrationSensor=PUSH2;
int i=0;
#define count_max 25
char SensorRead(int pin) // read sw with debounce
{
char count_low=0,count_high = 0;
do
{
delay(1);
if (digitalRead(pin) == HIGH)
{
count_high++;
count_low = 0;
}
else
{
count_high = 0;
count_low++;
}
}while(count_low< count_max && count_high < count_max);
if (count_low >= count_max)
return LOW;
else
return HIGH;
}
void setup()
{
GSM.begin(9600);
Serial.begin(9600);
GSM.println("AT");
delay(1000);
GSM.println("ATE0");
delay(1000);
GSM.println("AT+CMGF=1");
pinMode(led , OUTPUT);
digitalWrite(led, LOW);
pinMode(vibrationSensor, INPUT_PULLUP);
}
void loop()
{
if(SensorRead(vibrationSensor) == HIGH)
{
digitalWrite(led, HIGH);
gpsEvent();
Send();
digitalWrite(led, LOW);
delay(2000);
}
}
void gpsEvent()
{
char gpsString[55];
char test[]="RMC";
i=0;
while(1)
{
while (Serial.available()) //Serial incomming data from GPS
{
char inChar = (char)Serial.read();
gpsString[i]=inChar; //store incomming data from GPS to
temparary string str[]
i++;
if (i < 4)
{
if(gpsString[i-1] != test[i-1]) //check for right string
i=0;
}
if(i>50)
{
int degree=0;
degree=gpsString[16]-48;
degree*=10;
degree+=gpsString[17]-48;
int minut_int=0;
minut_int=gpsString[18]-48;
minut_int*=10;
minut_int+=gpsString[19]-48;
int minut_dec=0;
minut_dec+= (gpsString[21]-48)*10000;
minut_dec+= (gpsString[22]-48)*1000;
minut_dec+= (gpsString[23]-48)*100;
minut_dec+= (gpsString[24]-48)*10;
minut_dec+= (gpsString[25]-48);
float minut= ((float)minut_int + ((float)minut_dec/100000.0))/60.0;
latitude= ((float)degree + minut);
degree=0;
degree=gpsString[30]-48;
degree*=10;
degree+=gpsString[31]-48;
minut_int=0;
minut_int=gpsString[32]-48;
minut_int*=10;
minut_int+=gpsString[33]-48;
minut_dec=0;
minut_dec+= (gpsString[35]-48)*10000;
minut_dec+= (gpsString[36]-48)*1000;
minut_dec+= (gpsString[37]-48)*100;
minut_dec+= (gpsString[38]-48)*10;
minut_dec+= (gpsString[39]-48);
minut= ((float)minut_int + ((float)minut_dec/100000.0))/60.0;
logitude= ((float)degree + minut);
i=0;
Serial.flush();
return;
}
}
}
}
void Send()
{
GSM.print("AT+CMGS=");
GSM.print('"');
GSM.print("984****009"); // enter your Mobile number
GSM.println('"');
delay(500);
// GSM.print("Latitude:");
// GSM.println(latitude);
GSM.println("Accident Happned");
delay(500);
// GSM.print(" longitude:");
// GSM.println(logitude);
GSM.println("Click On link to see Location");
GSM.print(" http://maps.google.com/maps?&z=15&mrt=yp&t=k&q= ");
GSM.print(latitude,6);
GSM.print("+");
GSM.print(logitude,6);
GSM.write(26);
delay(4000);
}
10. LINE FOLLOWER
ROBOT USING MSP430
LAUNCHPAD
Line supporter robot is one of the well known mechanical technology
ventures among understudies and novices on account of its effortlessness. It
follows a line, either dark or white, contingent upon how you program your
microcontroller. Here we make a line devotee robot utilizing MSP430
launchpad from Texas Instruments, which follows the dark line. On the off
chance that you are new to MSP430 launchpad, if it's not too much trouble
read our Getting gazed with MSP430 Tutorial.

Materials Required

MSP430G2 LaunchPad from Texas Instruments

The L298D engine driver module

Interfacing wires

IR sensor Modules
Chasis, wheel, crazy ride

Energia IDE

Force supply (3.3v) and 5v-12v

Ideas of Line Follower

Idea of line adherent is identified with light. We have utilized the conduct of
light at highly contrasting surface. At the point when light fall on a white
surface it will practically full reflects and if there should be an occurrence
of dark surface light is consumed by dark surface. This clarified conduct of
light is utilized in this line adherent robot.
In this MSP430 based line supporter robot we have utilized IR Transmitters
and IR recipients likewise called photograph diodes. They are utilized for
sending along with getting light. IR transmits infrared lights. At the point
when infrared beams falls on white surface, it's reflected back along with
got by photodiodes which creates some voltage changes. At the point when
IR light falls on a dark surface, light is retain by the dark surface and no
beams are reflected back, subsequently photograph diode doesn't get any
light otherwise beams. To Learn increasingly about IR sensors, follow the
connection.
Here in this MSP430 based line adherent robot when sensor detects white
surface then MSP gets 1 as info and when detects dark line MSP gets 0 as
information.

Circuit Explanation

We can isolate the entire line devotee robot into different areas like sensor
segment, control segment and driver segment.

Sensor area: This segment contains IR diodes, potentiometer, Comparator


(Op-Amp) along with LED's. Potentiometer is utilized for setting reference
voltage at comparator's one terminal and IR sensors sense the line and give
an adjustment in voltage at comparator's subsequent terminal. At that point
comparator thinks about the two voltages and creates a computerized signal
at yield. Here in this circuit we utilized 2 comparator for 2 sensors. LM358
is utilized as comparator. LM358 has inbuilt 2 low clamor Op-amp.
Control Section: MSP430 Launchpad is utilized for managing the whole
procedure of line devotee robot. The yields of comparators are combined
with advanced pin P1_3 and P1_4 of MPS430 Launchpad. MSP430
Launchpad peruses these signs and send orders to driver circuit to drive line
supporter.
Driver segment: Driver segment comprises engine driver and two DC
engines. Engine driver is utilized for driving engines in light of the fact that
MSP430 Launchpad doesn't supply enough voltage and momentum to
engine. So we added an engine driver circuit to get enough voltage and ebb
and flow for engine. Here we have utilized the L298d driver for driving DC
Motors. MSP430 Launchpad sends orders to this engine driver and
afterward it drives engines.
We have created Line Follower Robots utilizing distinctive Micrcontroller:
Line Follower Robot utilizing 8051 Microcontroller

Line Follower Robot utilizing Arduino

Line Follower Robot utilizing Raspberry Pi

Line Follower Robot utilizing PIC Microcontroller

Working of Line Follower Robot utilizing MSP430

Working of line devotee is fascinating. Line supporter robot detects dark


line by utilizing sensor and afterward imparts the sign to MSP430
Launchpad. At that point MSP430 Launchpad drives the engine as per
sensors' yield.
Here in this venture we are utilizing 2 IR sensor modules specifically left
sensor along with right sensor. At the point when both left along with right
sensor detects white then robot push ahead.
Whenever left sensor goes ahead dark line then robot turn left side.
In the event that correct sensor sense dark line, at that point robot turn right
side until both sensor comes at white surface. At the point when white
surface comes robot begins proceeding onward forward once more.
On the off chance that the two sensors goes ahead dark line, robot stops.
Circuit Diagram

Circuit for this MSP430 Line Follower Robot is extremely straightforward.


The yield of comparators is straightforwardly associated with MSP430
Launchpad's advanced pin number p1_3 and P1_4. Also, engine driver's
information pin IN1, IN2, IN3 and IN4 are associated at MSP430
Launchpad's advanced pin P1_5, P2_0, P2_1, P2_2 separately. One engine
is associated at the yield pin of engine driver OUT1 and OUT2, and another
engine is associated at OUT3 and OUT4. Here we have utilized 3.3v stock
for power the whole circuit aside from Motor Driver module. We have
provided 8v to Motor driver module. The client can utilize 5v-12v.
You can likewise do your own IR module, similar to I based on Perf Board.
The following is the circuit for IR Module:
Programming Explanation

Complete Program is toward the finish of this Article.


In a program, above all, we characterize the information and yield pin for
sensor and engines. At that point characterize a few macros for the bearing
of line devotee and afterward compose an order to choose sensor yield
Note: Sensor might be dynamic low or dynamic high so first check what is
the yield of sensor at that point select order by remarking or uncommenting
activeLowMode. For dynamic HIGH, remark the activeLowMode full
scale.

#define l_sensor P1_3

#define r_sensor P1_4

int pins[4]={P1_5,P2_0,P2_1,P2_2};

#define forward 0x05


#define left 0x06

#define right 0x09

#define stop 0x00

//#define activeLowMode

#ifdef activeLowMode

int res[4]={forward,left,right,stop};

#else

int res[4]={stop,right,left,forward};

#endif

From that point onward, in arrangement work, we provide guidance to


sensor and engine pin. And afterward insider savvy work, we check inputs
and send yield to engine driver module to run the engines.

void setup()

for(int i=0;i<4;i++)

pinMode(pins[i], OUTPUT);

pinMode(l_sensor, INPUT);

pinMode(r_sensor, INPUT);
}

void loop()

int sense=(digitalRead(l_sensor)<<1) | digitalRead(r_sensor);

for(int i=0;i<4;i++)

digitalWrite(pins[i], (res[sense]>>i) & 0x01);

There are four conditions in this line adherent that we read by utilizing
MSP430 Launchpad. We have utilized two sensors specifically the left
sensor and the correct sensor.

Conditions: Active HIGH yield

Input Output
Movement Of
Left Right Robot
Left Motor Right Motor
Sensor Sensor

LM LM
LS RS RM1 RM2
1 2

0 0 0 0 0 0 Stop

0 1 1 0 0 0 Turn Right

1 0 0 0 1 0 Turn Left
1 1 1 0 1 0 Forward

Program is composed by the above table conditions.


Code
#define l_sensor P1_3
#define r_sensor P1_4
int pins[4]={P1_5,P2_0,P2_1,P2_2};
#define forward 0x05
#define left 0x06
#define right 0x09
#define stop 0x00
//#define activeLowMode
#ifdef activeLowMode
int res[4]={forward,left,right,stop};
#else
int res[4]={stop,right,left,forward};
#endif
void setup()
{
for(int i=0;i<4;i++)
pinMode(pins[i], OUTPUT);
pinMode(l_sensor, INPUT);
pinMode(r_sensor, INPUT);
}
void loop()
{
int sense=(digitalRead(l_sensor)<<1) | digitalRead(r_sensor);
for(int i=0;i<4;i++)
digitalWrite(pins[i], (res[sense]>>i) & 0x01);
}
11. I2C
CORRESPONDENCE WITH
MSP430 LAUNCHPAD
MSP430 is a ground-breaking stage gave by Texas Instruments to inserted
ventures, its adaptable nature has made it to discover ways into numerous
applications and the stage is as yet going. In case you have been following
our MSP430 instructional exercises, in this point you would have seen we
have just secured wide a scope of instructional exercises on this
microcontroller beginning from the very nuts along with bolts. Since now,
we have secured the rudiments we can get into all the more intriguing stuff
like the correspondence entry.
In the huge arrangement of implanted applications, no microcontroller can
play out all the exercises without anyone else. At some phase of time it
needs to convey to different gadgets to share data, there are a broad range of
kinds of correspondence conventions to share these information's, however
the most utilized ones are USART, IIC, SPI and CAN. Every
correspondence convention has its own preferred position and drawback.
How about we center around the I2C part for the time being since that is the
thing that we will learn in this instructional exercise.

What is I2C Communication Protocol?

The term IIC means "Bury Integrated Circuits". It is regularly indicated as


I2C or I squared C or even as 2-wire interface convention (TWI) at certain
spots however everything implies the equivalent. I2C is a synchronous
correspondence convention meaning, both the gadgets that are sharing the
data must share a typical clock signal. It has just two wires to share data out
of which one is utilized for the cockerel signal and the other is utilized for
sending and getting information.

How I2C Communication functions?


I2C correspondence was first presented by Phillips. As said before it has
two wires, these two wires will be associated across two gadgets. Here one
gadget is known as an ace and the other gadget is called as slave.
Correspondence ought to and will consistently happen between two a
Master along with a Slave. The upside of I2C correspondence is that
beyond what one slave can be associated with a Master.

The total correspondence happens through these two wires specifically,


Serial Clock along with Serial Data.
Sequential Clock (SCL): Shares the clock signal created by the ace with
the slave
Sequential Data (SDA): Sends the information to and from between the
Master and slave.
At some random time just the ace will have the option to start the
correspondence. Since there is more than 1 slave in the transport, the ace
needs to allude to each slave utilizing an alternate location. At the point
when tended to just the slave with that specific location will answer back
with the data while the others keep quit. In this way we can utilize a similar
transport to speak with various gadgets.
The voltage levels of I2C are not predefined. I2C correspondence is
adaptable, implies the gadget which is fueled by 5v volt, can utilize 5v for
I2C and the 3.3v gadgets can utilize 3v for I2C correspondence. However,
visualize a scenario where 2 gadgets which are running on various voltages,
need to convey utilizing I2C. A 5V I2C transport can't be associated with
3.3V gadget. For this situation voltage shifters are utilized to coordinate the
voltage levels between two I2C transports.
There are few arrangement of conditions which outline an exchange.
Introduction of transmission starts with a falling edge of SDA, which is
characterized as 'START' condition in underneath chart where ace leaves
SCL high while setting SDA low.

As appeared in the above chart underneath,


The falling edge of SDA is the equipment trigger for the START condition.
After this all gadgets on a similar transport go into listening mode.
In a similar way, rising edge of SDA stops the transmission which is
appeared as 'STOP' condition in above chart, where the ace leaves SCL high
and furthermore discharges SDA to go HIGH. So rising edge of SDA stops
the transmission.
R/W bit shows the bearing of transmission of following bytes, on the off
chance that it is HIGH methods the slave will transmit and on the off
chance that it is low methods the ace will transmit.
Each piece is transmitted on each clock cycle, so it takes 8 clock cycles to
transmit a byte. After every byte either sent or got, ninth clock cycle is held
for the ACK/NACK (recognized/not recognized). This ACK bit is produced
by either slave or ace contingent on the circumstance. For ACK bit, SDA is
set to low by ace or slave at ninth clock cycle. So it is low it considered as
ACK in case NACK.

Where to utilize I2C correspondence?

I2C correspondence is utilized uniquely for short separation


correspondence. It is positively dependable to a degree since it has a
synchronized clock heartbeat to do it savvy. This convention is for the most
part used to speak with sensor or different gadgets which needs to send data
to an ace. It is exceptionally convenient when a microcontroller needs to
speak with numerous other slave modules utilizing at least just wires. In
case you are searching for a long range correspondence you should attempt
RS232 and in case you are searching for increasingly dependable
correspondence you should attempt the SPI convention.

I2C in MSP430: Controlling AD5171 Digital Potentiometer

Energia IDE is one of the simplest programming to program our MSP430.


It is same as Arduino IDE. You can study Getting initiated with MSP430
utilizing Energia IDE here.
In this way, to utilize I2C in Energia IDE we need to simply incorporate
wire.h header record. Pin announcement (SDA and SCL) is inside the wire
library, so we not have to proclaim in arrangement work.
Test models can be found in Example menu of the IDE. One of the models
is clarified underneath:
This model tells the best way to control an Analog Devices AD5171 Digital
Potentiometer which imparts by means of the I2C synchronous sequential
convention. Utilizing MSP's I2C Wire Library, the computerized pot will
step through 64 degrees of opposition, blurring a LED.
In 1st place, we will incorporate the library liable for i2c correspondence
for example wire library

#include <Wire.h>

In arrangement work, we will start the wire library by .start() work.

void setup() {

Wire.begin();

At that point introduce a variable val to store estimations of potentiometer

byte val = 0;

In circle work, we will begin transmission to the i2c slave gadget (for this
situation Digital potentiometer IC) by indicating the gadget address which
is given in the datasheet of the IC.

void loop() {
Wire.beginTransmission(44); // transmit to device #44 (0x2c)

Thusly, line bytes for example information you need to send to the IC for
transmission with the compose() work.

Wire.write(byte(0x00)); // sends instruction byte

Wire.write(val); // sends potentiometer value byte

At that point transmit them by calling endTransmission().

Wire.endTransmission(); // stop transmitting

val++; // increment value

if (val == 64) { // if reached 64th position (max)

val = 0; // start over from lowest value

delay(500);

Code
#include <Wire.h>
byte val = 0;
void setup() {
Wire.begin();
}
void loop() {
Wire.beginTransmission(44); // transmit to device #44 (0x2c)
Wire.write(byte(0x00)); // sends instruction byte
Wire.write(val); // sends potentiometer value byte
Wire.endTransmission(); // stop transmitting
val++; // increment value
if (val == 64) { // if reached 64th position (max)
val = 0; // start over from lowest value
}
delay(500);
}
12. SENDING EMAIL
USING MSP430
LAUNCHPAD AND
ESP8266
We are moving towards the World of Internet of Things (IoT), an
innovation which is going to assume a significant job in the purchaser along
with mechanical hardware. Sending an Email from any Microcontroller or
Embedded framework is essential thing which is required in IoT. Here we
make a demo IoT venture where we use ESP8266 along with MSP430
Launchpad to send an email upon fire identification.

Parts Required

MSP430 Launchpad

ESP8266 Wi-Fi module

Fire Sensor

Interfacing wires

16x2 LCD

3.3v and 5v Power supply


10k POT

Bread Board or PCB

Preparing with you E-mail ID

For sending Email by means of Wi-Fi module and MSP430 Launchpad, we


have to have an email account which can be effectively made on
https://www.smtp2go.com/. After information exchange recollect the email
address along with secret word, which will be required in MSP430 program
later.
We additionally require to modify over the E-mail ID and secret key into
base 64 arrangement by utilizing this site https://www.base64encode.org/.
We are gonna to utilize this in our program

In this undertaking, a 16x2 Liquid Crystal Display is used for showing the
status of Wi-Fi Connection and Fire location messages. Here an email will
be sent at any point framework distinguishes any fire close to it.
To get the hang of sending email with ESP8266 utilizing other
microcontroller, experience underneath instructional exercises:

The most effective method to Send E-mail utilizing PIC


Microcontroller and ESP8266

Sending Email utilizing Arduino and ESP8266 WiFi Module

IoT Raspberry Pi Smart Container with Email Alert

Circuit Diagram and Explanation

Circuit for sending email utilizing MSP430 and ESP8266 is exceptionally


straightforward. For this undertaking we just need a MSP430 Launchpad
and ESP8266 Wi-Fi module. 16x2 LCD is utilized for showing different
messages, which is discretionary. ESP8266's Voltage Common Collector
along with GND pins are straightforwardly associated at 3.3V and GND.
What's more, CH_PD is likewise associated with 3.3V. A fire sensor is
utilized to trigger the MSP430 Launchpad to send Email Alert of fire.
Rx and Tx pins of ESP8266 is legitimately associated at pin P1_4 and P1_3
of MSP430 Launchpad. LCD's rs, RW, and en pins are straightforwardly
associated with P2_4 and P2_3. Information pins of LCD D4-D7 are
associated with P1_5, P2_0, P2_1, P2_2. LCD is controlled by utilizing 5v
supply and its ground is associated with MSP430 Launchpad's GND. Fire
sensor is associated at pin P2_5.
The following is the image and pinout of ESP8266:
On the off chance that you are new to MSP430, at that point follow our
beginning with MSP430 instructional exercise.

Code and Working Explanation

Programming some portion of this task is somewhat hard to comprehend for


a fledgling. Complete code for sending email through MSP430 is given
toward the end, here we have clarified barely any pieces of it.
Not surprisingly, first we need to incorporate libraries for LCD and
SoftwareSerial for interfacing LCD and ESP8266 separately. Programming
sequential library is utilized for sequential correspondence with ESP8266.
We have likewise characterized a pin for fire sensor module and taken a few
factors and cluster for putting away other information for estimation.

#include<LiquidCrystal.h>

LiquidCrystal lcd(P2_4, P2_3, P1_5, P2_0, P2_1, P2_2);

#include <SoftwareSerial.h>

SoftwareSerial ESP(P1_3, P1_4); // RX, TX

#define fireSensor P2_5

char str[40];

int i=0;

Underneath connect_wifi work is utilized for interfacing ESP8266 to Wi-Fi


set up. In this capacity, we have passed three contentions: order, reaction
and time to peruse the reaction. The code inside this capacity will be
consistently executed until ESP effectively interfaces with Wifi organize.

void connect_wifi(char *cmd, char *res, int t)

while (1)

for (int i = 0; i < 40; i++)


str[i] = NULL;

i = 0;

ESP.println(cmd);

Serial.print("-->");

Serial.println(cmd);

Serial.print("<--");

delay(t);

serialEvent1();

// Serial.println(str);

if (strstr(str, res))

return;

delay(1000);

After this, in arrangement work we introduce troubleshoot sequential port


and ESP Serial port, and provide guidance to fire sensor pin. At that point
we introduce LCD and give some invite message over LCD, at that point
instate Wi-Fi and interface it to a hotspot or Wi-Fi switch utilizing above
portrayed capacity.

ESP.begin(9600);
Serial.begin(9600);

pinMode(fireSensor, INPUT);

lcd.begin(16,2);

lcd.print("Email Alert ");

lcd.setCursor(0,1);

lcd.print("By MSP430");

delay(2000);

lcd.clear();

lcd.print("Hello_world");

delay(2000);

lcd.clear();

lcd.print("Finding ESP8266");

lcd.setCursor(0,1);

lcd.print("Please Wait...");

connect_wifi("AT", "OK", 1000);

connect_wifi("ATE0", "OK", 1000);

connect_wifi("AT+CWMODE=3", "OK", 1000);

connect_wifi("AT+CWQAP", "OK", 1000);


lcd.clear();

lcd.print("Connecting WiFi");

Serial.println("Connecting Wifi....");

After effectively associating with hotspot or Wi-Fi switch, it comes in circle


work where it trusts that a trigger will send email. Here fire sensor will start
that trigger at whatever point it identifies fire.
At whatever point fire sensor gets initiated, MPS430 sends an email. Prior
to sending email, it designs the email setting and interfaces with Email
server. At that point it plans body with the message given in the code
underneath and sends it to recepient email address that we have given in
email arrangements.

else

lcd.clear();

lcd.print("Fire Alert ");

lcd.setCursor(0,1);

lcd.print("Sending Email");

//lcd.print("Configuring Email..");

ESP.println("AT+CIPMUX=1");

delay(1000);

ESP.println("AT+CIPSERVER=1,80");
delay(2000);

ESP.println("AT+CIPSTART=4,\"TCP\",\"mail.smtp2go.com\",
2525");

delay(2000);

ESP.println("AT+CIPSEND=4,180");

delay(2000);

ESP.println("EHLO 192.168.1.123");

ESP.println("AUTH LOGIN");

ESP.println("c2FkZGFtNDIwMUBnbWFpbC5jb20=");

ESP.println(" tu934yt89ert83=");

ESP.println("MAIL FROM:<helloworld007@gmail.com>");

ESP.println("RCPT To:<helloworld007@gmail.com>");

ESP.println("DATA");

// ESP.println("Testing Success.");

ESP.println("Fire Alert from Arduino");

ESP.println(".");
Note: Many email servers won't acknowledge email from the IP addresses
gave by obscure server.
We need to enter recepient email, sender email and secret word in
base64encoded group, which we have changed over in past area utilizing
https://www.base64encode.org/site.
Check the total clarification.

Code
#include<LiquidCrystal.h>
LiquidCrystal lcd(P2_4, P2_3, P1_5, P2_0, P2_1, P2_2);
#include <SoftwareSerial.h>
SoftwareSerial ESP(P1_3, P1_4); // RX, TX
#define fireSensor P2_5
char str[40];
int i=0;
void connect_wifi(char *cmd, char *res, int t)
{
while (1)
{
for (int i = 0; i < 40; i++)
str[i] = NULL;
i = 0;
ESP.println(cmd);
Serial.print("-->");
Serial.println(cmd);
Serial.print("<--");
delay(t);
serialEvent1();
// Serial.println(str);
if (strstr(str, res))
return;
delay(1000);
}
}
void setup()
{
ESP.begin(9600);
Serial.begin(9600);
pinMode(fireSensor, INPUT);
lcd.begin(16,2);
lcd.print("Email Alert ");
lcd.setCursor(0,1);
lcd.print("By MSP430");
delay(2000);
lcd.clear();
lcd.print("Hello_world");
delay(2000);
lcd.clear();
lcd.print("Finding ESP8266");
lcd.setCursor(0,1);
lcd.print("Please Wait...");
connect_wifi("AT", "OK", 1000);
connect_wifi("ATE0", "OK", 1000);
connect_wifi("AT+CWMODE=3", "OK", 1000);
connect_wifi("AT+CWQAP", "OK", 1000);
lcd.clear();
lcd.print("Connecting WiFi");
Serial.println("Connecting Wifi....");
connect_wifi("AT+CWJAP=\"Redmi\",\"arishkhan\"","CONNECTED",
7000);
lcd.clear();
lcd.print("WIFI Connected...");
Serial.println("Wifi Connected");
ESP.println("AT+CIFSR");
delay(5000);
}
void loop()
{
if(digitalRead(fireSensor))
{
lcd.setCursor(0,0);
lcd.print("No Fire ");
}
else
{
lcd.clear();
lcd.print("Fire Alert ");
lcd.setCursor(0,1);
lcd.print("Sending Email");
//lcd.print("Configuring Email..");
ESP.println("AT+CIPMUX=1");
delay(1000);
ESP.println("AT+CIPSERVER=1,80");
delay(2000);
ESP.println("AT+CIPSTART=4,\"TCP\",\"mail.smtp2go.com\",2525");
delay(2000);
ESP.println("AT+CIPSEND=4,180");
delay(2000);
ESP.println("EHLO 192.168.1.123");
ESP.println("AUTH LOGIN");
ESP.println("c2FkZGFtNDIwMUBnbWFpbC5jb20=");
ESP.println(" tu934yt89ert83=");
ESP.println("MAIL FROM:< helloworld007@gmail.com >");
ESP.println("RCPT To:< helloworld007@gmail.com >");
ESP.println("DATA");
// ESP.println("Testing Success.");
ESP.println("Fire Alert from Arduino");
ESP.println(".");
delay(2000);
ESP.println("AT+CIPSEND=6");
delay(1000);
ESP.println("QUIT");
delay(1000);
lcd.clear();
lcd.print("Email Sent...");
delay(2000);
lcd.clear();
}
}
void serialEvent1()
{
int ln=ESP.available();
if(ln>0)
{
for(int i=0;i<ln;i++)
{
char ch=ESP.read();
str[i]=ch;
Serial.print(ch);
delay(1);

}
}
}
13. RFID INTERFACING
WITH MSP430
LAUNCHPAD
In this instructional exercise we plan a framework to peruse the RFID cards
utilizing MSP430 and RFID Reader. RFID represents Radio Frequency
Identification. Each card has a special ID and this settles on it an ideal
decision for some validation applications, as in workplaces, shopping
centers and in numerous different spots where just the individual with
approval card is permitted to enter inside. RFID is utilized in shopping
centers to prevent a burglary from occurring, where the item will be labeled
with RFID chip and on the off chance that anybody leaves the structure
with the RFID chip an alert is raised naturally thus the robbery is halted.
The RFID tag is planned as little as grain of sand. The RFID verification
frameworks are anything but difficult to structure and are modest in cost. A
few schools and universities these days use RFID as participation register.

Materials Required

1. MSP430 Launchpad
2. EM-18 (RFID peruser module)
3. 16*2 LCD
4. Potentiometer
5. Breadboard
6. Jumper wires

Programming: Energia IDE

EM-18 RFID Reader

Each RFID card has a one of a kind ID implanted in it and a RFID peruser
is utilized to peruse the RFID card no. EM-18 RFID peruser works at 125
KHz and it accompanies an on-chip radio wire and it very well may be
fueled with 5V power supply. It gives sequential yield along weigand yield.
The range is around 8-12cm. sequential correspondence parameters are
9600bps, 8 information bits, 1 stop bit. This remote RF Identification is
utilized in numerous frameworks like

RFID Based Attendance System,

Security frameworks,

Casting a ballot machines,

E-cost street estimating

Check all the RFID Projects here.


The yield gave by EM-18 RFID peruser is in 12 digit ASCII position. Out
of 12 digits initial 10 digits are card number and the last two digits are the
XOR aftereffect of the card number. Last two digits are utilized for blunder
checking.
For instance, card number is 0200107D0D62 perused from the peruser then
the card number on the card will be as underneath.
02 – prelude
00107D0D = 1080589 in decimal.
62 is XOR esteem for (02 XOR 00 XOR 10 XOR 7D XOR 0D).
Subsequently number on the card is 0001080589.
MSP430 RFID Reader Circuit Diagram and Working

We will utilize Hardware UART of MSP430 in this way, ensure RXD and
TXD jumpers on the board are on HW UART mode. At that point associate
Tx of EM-18 to RXD(P1.1) of MSP430.
Before going to assist we have to comprehend about the sequential
correspondence. The RFID module here sends information to the controller
in sequential. It has other method of correspondence however for simple
correspondence we are picking RS232. The RS232 pin of module is
associated with RXD pin of MSP430.
The information sent by the RFID module goes as:
Presently for setting up an association between RFID peruser and MSP430,
we have to empower the sequential correspondence in MSP430. The
sequential correspondence empowering in MSP430 should be possible by
utilizing a solitary order.

Serial.begin(9600);

data = Serial.read();

As appeared in figure over, the correspondence of RFID is finished by a


BAUD pace of 9600 bits for each second. So for MSP430 to set up such
baud rate and to begin sequential correspondence we use order
"Serial.begin(9600);". Here 9600 is the baud rate and is variable.
Presently once baud rate is set, MSP is prepared to get the sequential
information. This information is gotten by order "information =
Serial.read();". By this order sequential information is taken in 'information'
named number.
When a card is brought close to peruser, the peruser peruses the sequential
information and sends it to MSP, the MSP will be modified to show that
esteem in LCD, so we will have ID of card on LCD.
Code and Explanation

We will compose our code in Energia IDE. It is same as Arduino IDE along
with simple to utilize. Complete code is given toward the finish of this
venture, here we are clarifying not many pieces of it.
In the 1st place, incorporate library for LCD show and pronounce singe
cluster to store RFID number.

#include <LiquidCrystal.h>

LiquidCrystal lcd(P2_0, P2_1, P2_2, P2_3, P2_4, P2_5);

char input[12];
In arrangement work, empower LCD and sequential correspondence by
characterizing Baud pace of 9600.

void setup()

lcd.begin(16, 2);

Serial.begin(9600);

...

..

In circle work, we will check sequential information is accessible or not. In


the event that accessible, store the information in input[count] cluster from
Serial.read() and show it on the LCD individually utilizing while circle.

while(Serial.available() && count < 12) // Read 12 characters and


store them in input array

input[count] = Serial.read(); //storing 12 characters one by


one

Serial.print(input[count]);

lcd.print(input[count]);

delay(300);

count++;
if (count==12)

lcd.print(" ");

count = 0; // once 12 characters are read get to start


and wait for second ID

This is the manner by which we can peruse and show the RFID number on
LCD utilizing MSP430 Launchpad. Presently you can additionally expand
this extend and can manufacture Attendance framework, casting a ballot
framework, security framework and so on.

Code
#include <LiquidCrystal.h>
LiquidCrystal lcd(P2_0, P2_1, P2_2, P2_3, P2_4, P2_5);
char input[12];
int count = 0;
void setup()
{
lcd.begin(16, 2);
Serial.begin(9600);
lcd.setCursor(0, 0);
lcd.print("Welcome..");
delay(3000);
lcd.clear();
lcd.print("Place Card to");
lcd.setCursor(0, 1);
lcd.print("scan");
}
void loop()
{
if(Serial.available()==0){
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Place Card to scan");
for (int positionCounter = 0; positionCounter < 13; positionCounter++) {
// scroll one position left:
lcd.scrollDisplayLeft();
// wait a bit:
delay(150);
}
}
if(Serial.available()>0){
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("RFID No. ->");
lcd.setCursor(0, 1);
delay(30);
}
while(Serial.available() && count < 12) // Read 12 characters and
store them in input array
{
input[count] = Serial.read(); //storing 12 characters
Serial.print(input[count]);
lcd.print(input[count]);
delay(300);
count++;

if (count==12)
{
lcd.print(" ");
count = 0; // once 12 characters are read get to start and wait for
second ID
lcd.setCursor(0, 1); //move courser to start
}
}
delay(3000);
}
14. INTERFACING RTC
MODULE (DS3231) WITH
MSP430: DIGITAL CLOCK
In this instructional exercise we will make a Digital Clock by interfacing
RTC module DS3231 with MSP430 and show the time along with date on
16x2 Liquid Crystal Display. The MSP-EXP430G2 is a Development Tool
a.k.a LaunchPad gave by the Texas Instruments to learn and rehearse on the
best way to utilize their Microcontrollers. This board falls under the
MSP430 Value Line classification where we can program all the MSP430
arrangement Microcontrollers. On the off chance that you are new to MSP,
at that point check our beginning with MSP430 instructional exercise.

Materials Required:

MSP430

DS3231 RTC module

POT - 10k

Liquid Crystal Display Module 16*2

Associating wires
Breadboard

What is RTC??

DS3231 is a RTC (Real Time Clock) module. It is utilized to maintain up


the date and time for a large portion of the Electronics ventures. This
module has its own coin cell power supply utilizing which it keeps up the
date and time in any event, when the principle power is expelled or the
MCU has experienced a hard reset. So once we set the date along with time
in this module it will monitor it generally. There are a some types of RTC
ICs accessible like DS1307, DS3231 and so forth.

We have recently utilized RTC with Other microcontrollers in underneath


ventures:

Programmed Pet Feeder utilizing Arduino

Arduino Data Logger

Interfacing RTC Module (DS3231) with PIC Microcontroller

Raspberry Pi Alarm Clock

Note: When utilizing this module just because you need to set the date
along with time. You can likewise utilize RTC IC DS1307, we have
recently utilized DS1307 with Arduino.
Interfacing the DS3231 RTC with MSP430:
Circuit chart for MSP430 Microcontroller based Digital Clock is given
underneath. As told before the DS3231 works with the assistance of I2C
correspondence so it will have a Serial Clock (SCL) and a Serial Data
(SDA) pin which must be associated with the I2C nails to our MSP430
which is the pin 9(PIN 2.1,SCL) along with pin 10 (PIN 2.2,SDA).
MSP430 gives 3.3V Vcc yet we need 5V to interface it with LCD and RTC
module. In this way, we will utilize a hack, there is a jumper accessible
named as TP1 close to USB link connector. You can take 5V from that
point.

Circuit Diagram:

Programming MSP430 for RTC Module:


Here we are utilizing Energia IDE for programming. It is same as Arduino
IDE along with simple to utilize. On the off chance that you are new to
MSP and energia, at that point experience beginning with MSP utilizing
Energia IDE. To interface RTC module we require library for this board.
Install RTC library from this connection and introduce it.
We likewise require Wire (utilized for I2C correspondence) and
liquidcrystal libraries which are preinstalled in Energia IDE.
Complete code for this MSP430 computerized clock is given toward the
finish of this article. Code is basic and effectively reasonable. Here we are
clarifying not many pieces of it.
Initially, we require to incorporate important libraries.
Beneath library is for I2C correspondence between RTC module and
MSP430. SDA and SCK pins are now characterized in this library, so we
don't need to pronounce these pins independently.

#include <Wire.h>

At that point we have included RTClib.h library for RTC clock along with
LiquidCrystal.h for LCD capacities.

#include "RTClib.h"

#include <LiquidCrystal.h>

After this, we require to make an occurrence to instate our RTC module.

RTC_DS3231 rtc;

At that point make a variety of size 7 and store every one of the seven days
with name in it.
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday"};

Here is Pins presentation of MSP430 to be utilized by LCD show:


(RS(P2.0),EN(P1.4),D4(P1.5),D5(P2.3),D6(P2.4),D7(P2.5))

LiquidCrystal lcd(8 ,6, 7,11,12,13);

In void arrangement(), we have instated the interface to the LCD screen and
RTC and indicated the measurements (width and stature) of the showcase,
start() should be called before some other library orders.

void setup () {

lcd.begin(16, 2);

lcd.setCursor(3,0);

lcd.print("RTC Clock");

delay(3000);

lcd.clear();

rtc.begin();

// rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));

NOTE: In above capacity, remarked line is significant. At the point when


Time along with Date isn't set, uncomment the line and transfer the
program. This capacity store time of your PC at the hour of Compilation, so
ensure your PC's time is right.
Presently, Time appeared in plain view is right yet there is an issue, each
time you restart/reset your microcontroller, LCD will show Time at which
you transferred the code. This is on the grounds that rtc.adjust() work has
put away the hour of your PC, so when you reset, it begins with that time.
To fix this issue, first transfer the program with rtc.adjust() work
uncommented. At that point, quickly remark a similar line and transfer the
program once more. Presently, your date along with time is set and won't be
influenced by resetting the microcontroller.
In circle work we takes date along with time from RTC module and store in
the predefined variable called now and show it on LCD utilizing lcd.print()
work.

void loop () {

DateTime now = rtc.now();

lcd.clear();

lcd.setCursor(3,0);

lcd.print(now.day(), DEC);

lcd.print("/");….

…….

Complete code is given beneath.

Code
#include <Wire.h>
#include "RTClib.h"
#include <LiquidCrystal.h>
RTC_DS3231 rtc;
char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday"};
LiquidCrystal lcd(8 ,6, 7,11,12,13);
void setup () {
lcd.begin(16, 2);
lcd.setCursor(3,0);
lcd.print("RTC Clock");
delay(3000);
lcd.clear();
rtc.begin();
// rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}
void loop () {
DateTime now = rtc.now();
lcd.clear();
lcd.setCursor(3,0);
Serial.print(now.year(), DEC);
Serial.print('/');
lcd.print(now.day(), DEC);
lcd.print("/");
lcd.print(now.month(), DEC);
lcd.print("/");
lcd.print(now.year(), DEC);
lcd.setCursor(1,5);
lcd.print(daysOfTheWeek[now.dayOfTheWeek()]);
lcd.print(",");
lcd.print(now.hour(), DEC);
lcd.print(":");
lcd.print(now.minute(), DEC);
lcd.print(":");
lcd.print(now.second(), DEC);
delay(1000);
}
15. INTERFACING
STEPPER MOTOR WITH
MSP430G2
In this instructional exercise we will Interface Stepper Motor utilizing
MSP430. The MSP-EXP430G2 is a Development Tool a.k.a LaunchPad
gave by the Texas Instruments to learn and rehearse on the most proficient
method to utilize their Microcontrollers. This board falls under the MSP430
Value Line classification where we can program all the MSP430
arrangement Microcontrollers. In the event that you are new to MSP, at that
point check our beginning with MSP430 instructional exercise.

Stepper Motor:

Stepper Motor is a kind of brushless DC Motor which changes over


electrical heartbeats into unmistakable mechanical developments. The pole
of a stepper engine turns in discrete advances. We can get exact advances
and speed as indicated by our need.
We will utilize 35BYJ46 Bi-polar stepper engine which is economically
accessible in the market. It has 6 wires yet it accompanies 5 wires
moreover. There are 2 curls in our stepper engine. Every ha 3 wires coming
out of it. Out of 3 wires, 1 is focused tapped thus, staying 2 wires associated
with curl legitimately. Altogether, we have 4 sign wires and 2 focused
tapped wires which are associated with 5-12V force supply.
On the off chance that, on the off chance that there are all out 5 wires
coming out of engine, at that point 4 wires are signal wires and 1 is focused
tapped to the two loops. Like this.

To check which wire is focused tapped or which is signal wire, you need to
look at obstruction of wires happening to the engine. In this way, those
wires, which are associated with a similar loop, has high obstruction esteem
when contrasted with opposition of focused tapped.
In above chart, on the off chance that we have checked obstruction
estimation of Blue and Yellow wires and opposition between them is more
than the incentive among Yellow and Red or Blue along with Red. In this
way, Red is focused Tapped wire.
We have beforehand interfaced Stepper Motor with different
Microcontrollers:

Interfacing Stepper Motor with Arduino Uno

Stepper Motor Control with Raspberry Pi

Stepper Motor Interfacing with 8051 Microcontroller

Interfacing Stepper Motor with PIC Microcontroller

Stepper engine can likewise be controlled with no Microcontroller, see this


Stepper Motor Driver Circuit.

ULN2003 Stepper Motor Driver:

Most stepper engines will work just with the assistance of a driver module.
This is on the grounds that the controller module (For our situation MSP)
won't have the option to give enough current from its I/O pins for the
engine to work. So we will utilize an outer module like ULN2003 module
as stepper engine driver. There are a numerous kinds of driver module and
the rating of one will change dependent on the sort of engine utilized. The
essential guideline for all driver modules will be to source/sink enough ebb
and flow for the engine to work.
In this venture, we will utilize ULN2003 engine driver IC. Pin chart of IC is
given underneath:
We will utilize 4 info and 4 yield port if IC.

Materials Required:

MSP430

35BYJ46 or 28-BYJ48 Stepper engine

ULN2003 IC

Wires

Breadboard

Circuit Diagram:
In above graph, RED wire of stepper isn't associated with PIN5 of IC .It
must be associated with 5V. Shading code of your Stepper engine might be
unique in relation to the hues given in the circuit chart. In this way,
interface the wires in case of checking the right sign wires.
We will compose our code utilizing Energia IDE. It is same as Arduino IDE
and simple to utilize. Test code for driving the stepper can similarly be
found in model menu of Arduino IDE.

Code and Working Explanation:

Before we initiate programming with our MSP430, let us comprehend what


ought to really occur inside the program. We will utilize 4-advance
grouping strategy so we will have four stages to perform for making one
complete revolution. Think about A, B, C and D as four curls.

Pin Coils
Step
Energized Energized

Step
6 and 7 A and B
1

Step
7 and 8 B and C
2

Step
8 and 9 C and D
3

Step
9 and 6 D and A
4

Here, we will compose the MSP430 stepper engine code . The total
program can be found toward the finish of the instructional exercise barely
any significant lines are clarified underneath.
The quantity of steps per insurgency for our stepper engine was determined
to be 32; henceforth we enter that as appeared in the line underneath

const int STEPS = 32;

Next you need to make occurrences in which we determine the pins to


which we have associated the Stepper engine.

Stepper myStepper (STEPS, 6, 7, 8, 9);

Since we are utilizing the Stepper library, we can set the speed of the engine
utilizing the beneath line. The speed can run between 0 to 200 for 35BYJ46
stepper engines.

Mystepper.setSpeed(200);

Presently, to make the engine move one stage we can utilize the
accompanying line.

myStepper.step(STEPS);

Since we have 32 stages and 64 as the rigging proportion we have to move


2048 (32*64=2048), to make one complete pivot. Presently, transfer the
underneath code and change the no. of steps as per your need.
This is the way you can interface stepper engine with a PIC
Microcontroller, now you can utilize your own innovativeness and discover
applications for this. There are bundles of ventures out there which utilize a
stepper engine.

Code
#include <Stepper.h>
const int STEPS = 32; // change this to fit the number of steps per
revolution
// for your motor
// initialize the stepper library on pins 6 through 9 or you can use any pins
on MSP430:
Stepper myStepper(STEPS, 6,7,8,9);
void setup() {
// set the speed at 200rpm or as you want:
myStepper.setSpeed(200);
}
void loop() {
myStepper.step(STEPS);
}
16. BEGINNING WITH
MSP430 UTILIZING CODE
COMPOSER STUDIO-
BLINKING A LED
The MSP-EXP430G2 is a Growth Tool a.k.a LaunchPad gave by the Texas
Instruments to learn and rehearse on the best way to utilize their
Microcontrollers. This board falls under the MSP430 Value Line class
where we can program all the MSP430 arrangement Microcontrollers.
Figuring out how to utilize TI Microcontrollers would be a powerful device
up in our sleeve since TI is extremely immense and has a wide verity of
MCU's to browse at a less serious cost.
We previously secured definite article on utilizing Energia IDE with
MSP430. Here we will find out about Code Composer Studio along with
how it is utilized to program MSP430. This instructional exercise is
composed for very fledglings and no equipment is required with the
exception of the MSP430 board and a PC. Toward the finish of this
instructional exercise we will have the option to Blink the installed LED of
MSP430.

MSP-EXP430G2 Development Board:

The perfect red shading board is the MSP-EXP430G2 Development Board.


This board can program TI Microcontrollers that fall under the MSP430
arrangement. The principle motivation behind this board it to transfer code
from the PC to the MCU and read sequential information from the MCU for
troubleshooting reason. It likewise gives the pin-out to each stick of the
MCU and furthermore two LEDs and a press catch to make advancement
simple. The board has developed a great deal since its dispatch and the one
appeared underneath is the MSP_EXP430G2 Rev1.5.

The MSP430G2553 has preferred details over the different arrangement, it


additionally has a UART module which would be exceptionally convenient
while troubleshooting utilizing Code Composer Studio. Consequently in
this arrangement, we will utilize the MSP430G2553 to investigate all the
functionalities of this Development pack.

Controlling and Testing the advancement board:

Before we initiate anything TI would have just transferred an example


Program on your MSP430G2553 Microcontroller, so let us power the board
and check in case it is working. You can control board through the smaller
than normal USB jack and once you do it, you must view the LEDs (red
and green) at the base left corner of your board sparkling then again. You
would then be able to press the press button associated with P1.3 to check if
the inside temperature sensor is working. Truly, the MSP2553 has an
inward temperature sensor, in the wake of squeezing the catch simply rub
your fingers to warm it up and place it on the IC you can view the Red LED
goes on to demonstrate the ascent in temperature. Cool!! Right?? OK
presently, let us proceed onward to the Software Environment.
Programming Software (IDE) for MSP430 LaunchPad:

Texas Instruments permits us to program their Microcontrollers across an


assortment of Environments. The Official one is the Code Composer Studio
regularly known as the CCS. This product is accessible liberated from cost.
Additionally, it requires some negligible degree of involvement in
Microcontrollers. Try not to stress we will cover each progression to get
acquainted with CCS.
There is 1 more IDE accessible to compose our program for example
Energia IDE. In this way, what is the distinction among CCS and Energia
IDE. We previously canvassed Energia IDE in our past Tutorial.

Energia IDE versus Code Composer Studio:

Energia is an Open source and free Environment that empowers us to


program the TI Microcontrollers without any problem. The primary point of
Energia is to do programming TI MCU's as simple as programming in
Arduino. So Energia is an Equivalent for Arduino that underpins Texas
Instruments Microcontrollers. Individuals who have utilized Arduino will
concur more on this once they download and dispatch the Energia IDE.
Code Composer Studio (CCS) is an increasingly adaptable expert IDE
which has more functionalities and capacities regarding getting to within
design of microcontroller. It has inbuilt troubleshooting capacity which can
check mistakes in your code and you can run your code line by line that
helps in discovering blunder with no migraine. It will take at certain
moments to get settled with CCS. When you set with this amazing
programming, trust me you will become more familiar with anything about
a specific microcontroller. You require to take help of Datasheet of the
microcontroller to compose your program.
On the off chance that you are completed with Arduino iDE or Energia
IDE, change your coding condition to CCS, it is most requesting
programming in Industries.

Installing along with Launching the Code Composer Studio:

This product is accessible at Texas Instrument's site with no expense. In this


way, you can install it from the given connection Download interface .We
will utilize Code Composer Studio V7 yet you can download most recent
form additionally, methodology stays same.

It is possible that you can install entire programming utilizing web installer
or download arrangement/disconnected installer. This product is very
substantial around 1GB along these lines, you have to hold up until it
completed the process of downloading.
In case of installing the product, open it and introduce.
At the point when you click on arrangement, much the same as some other
programming you will be approached to concur terms along with conditions
along with to choose the establishment envelope. After that you require to
pick sheets for which you require to download documents. For our situation
we are utilizing MSP430 MCU, click on first choice. You can download
more than 1 board records.

Next window is to choose investigate test. Naturally one choice is


accessible in this way, click on it and finish. Presently, your establishment
will begin so simply hold up until it wrapped up.
After establishment, it gets some information about workspace envelope so
pick the organizer where you require to spare your records and snap Ok.

In this way, how about we investigate the principal window that we will
view.
This is a straightforward interface where you can view Getting started menu
in which you can begin to make your venture, close to beginning there is a
Resource Explorer. This is a wonderful component of this product where
you can discover everything about a TI item like datasheets,
documentations, along with etc. There is no compelling reason to discover
datasheets on web, simply click on asset traveler and snap on the gadget
which you need to investigate after that you can see everything about the
item.
Making first Project in Code Composer Studio: Blink a LED:
Making Project in CCS:
Stage 1:- Click on File - > New - > CCS venture. As demonstrated as
follows
Stage 2:- Next, you require to pick MSP board that you are utilizing. I am
utilizing MSP430G2553 in this way, I will pick this as appeared.
Offer name to your task and snap on finish.
When you click on finish, another window will open with certain lines code
previously composed into it.
Composing Code in CCS:

How about we see the shape of the code that is now given. First line is our
header document which relies upon the variation that we pick while making
the undertaking. As I told I am utilizing MSP430G2553, so I'll rename the
header record to

#include<msp430g2553.h>

Next line is the fundamental capacity. In the primary capacity you will view
instatement of Watchdog clock. MSP430 along with other TI based
microcontroller has extraordinary kind of clock which is known as
Watchdog clock . Work of this clock is to rset the microcontroller when it
starts to hanging or quit giving reaction. In our code, we won't use
Watchdog clock since it is over the learner's viewpoint. At the point when
we ON the Microcontroller, guard dog clock is ON as a matter of course so
we require to OFF this clock by composing this line

WDTCTL = WDTPW | WDTHOLD;

Presently, we require to compose code to flicker installed Light Emitting


Diode which is associated with P1.0. There is another LED associated with
P1.6. We will utilize just previously LED. You can compose code for
flipping these two LED's likewise after you comprehend the squint
program.
To start with, we need to pronounce these PINS as we are utilizing these as
INPUT or OUTPUT.
There are several kind of Registers for example memory squares used to
control PORTS. In this way, for characterizing PORT as INPUT or
OUTPUT, PXDIR (X is port no.) (Data Direction Register) register is
utilized. On the off chance that PXDIR is 1 it goes about as OUTPUT along
with 0 for INPUT. Our Light Emitting Diode is at port no. 1 so we will
compose as P1DIR .
We have to design PIN 0, as our LED is combined with this PIN and it is
OUTPUT. Each port has eight bits along with we need Bit0 as HIGH to do
it OUTPUT. In this way, we appoint P1DIR as

P1DIR = 0b00000001; it is in binary , we can also write it in


Hexadecimal i.e.

P1DIR = 0x01;

Next, we require to set the specific pin of specific port as high or low. For
this reason we require to utilize P1OUT register, 1 for high while 0 for low.
At first, I do the LED ON by setting BIT0 as 1 different stays zero.

P1OUT=0b00000001 ;
P1OUT = 0x01; // in hexadecimal

As there is no inbuilt capacity of postponement in MSP430 in this way, we


need to use for circle to give delay.
Thus, in following stage, we require to pronounce a variable 'I' for postpone
reason which can be composed as

Unsigned int i;

To start with, we will make PIN0 HIGH and give some defer utilizing FOR
circle after that do the PIN LOW. In this way, we get flickering impact. We
compose program this way:

P1OUT=0X01; //make bit0 HIGH

for (i=0;i<20000;i++){ // delay till you make LED HIGH

P1OUT=0X00; //make bit0 LOW

for (i=0;i<20000;i++){ // delay till you make LED LOW

You can compose this code in another manner too. You can utilize
BITWISE administrator to lessen lines of code. There are OR, and XOR
bitwise administrators accessible. You can utilize XOR administrator (^) .
XOR activity gives 1 when the 2 bits are equivalent like 1 and 1, 0 and 0
.We compose it like this

P1OUT ^= 0x01;
which implies P1OUT = P1OUT xor 0b00000001;
In this way, at first we introduce P1OUT as 0b00000001, in the event that
we take xor activity with 0b00000001, yield will be 0b00000000 methods
our LED will be OFF. After this we put for circle for defer reason.

while (1)

P1OUT ^=0X01; //toggle the bits

for (i=0;i<20000;i++){ // delay till you make LED LOW


HIGH

Transfer the code into MSP430 :

Complete program for CCS is given toward the finish of the page. So our
code is prepared to consume in MSP430. In this way, interface MSP with
your PC utilizing USB link.
Presently, we require to incorporate/form our code, for this snap on Project
- > Build All. Check the report of aggregation in the comfort box at the base
of the window. It will show "Fabricate Finished".
It's a great opportunity to transfer the program. Snap on Run - > Debug. In
the wake of tapping on troubleshoot, you will get a window identified with
power sparing, simply click on continue. In investigate choice go to Run-
>Resume. On the off chance that your alternatives are blanked out, no
compelling reason to stress, go to View->Debug and afterward again go to
Run->Resume.
When you fixed the code, your program is transferred in the MSP. An easy
route path is to just tap the play/stop like catch on the screen. The
investigate screen will resemble, as given underneath

Whenever LED isn't squinting at that point Reset the board or associate the
USB again.
SO this is the means by which you can compose a basic program in Code
Composer Studio to squint a LED utilizing MSP430.
Code
#include <msp430g2553.h> // header file that depends upon your board
/*
* main.c
*/
int main(void) {
WDTCTL = WDTPW | WDTHOLD;// Stop watchdog timer
P1DIR = 0X01; //Declare PIN0 OF PORT 1 AS OUTPUT
P1OUT = 0X01; //MAKE PIN0 HIGH INITIALLY
unsigned int i; //Delay variable
while(1)
{
P1OUT ^=0X01; ////toggle the bits
for(i=0;i<20000;i++){ // delay till you make LED LOW HIGH
}
}
return 0;
}
17. INTERFACING SERVO
MOTOR WITH MSP430G2
In this instructional exercise we will find out about Servo Motor and How
to interface Servo with MSP430. The MSP-EXP430G2 is a Development
Tool a.k.a LaunchPad gave by the Texas Instruments to learn and rehearse
on the most proficient method to utilize their Microcontrollers. This board
falls under the MSP430 Value Line class where we can program all the
MSP430 arrangement Microcontrollers. On the off chance that you are new
to MSP, at that point check our beginning with MSP430 instructional
exercise.

Servo Motor along with PWM:

Prior to really expounding, first we should think about Servo Motors.


A Servo Motor is a blend of DC engine, position control framework and
riggings. Servos have numerous applications in the cutting edge world and
with that, they are accessible in various shapes along with sizes. We will
use SG90 Servo Motor in this instructional exercise, it is the mainstream
and least expensive one. SG90 is a 180 degree servo. So with this servo we
can situate the pivot from 0-180°.
A Servo Motor mostly has 3 wires, 1 is for +ve voltage, another is for
ground along with last 1 is for position setting. The Red wire is associated
with power, Brown wire is associated with ground and Yellow wire (or
WHITE) is associated with signal.

Every servo engine works on an alternate PWM frequencies (most basic


recurrence is 50HZ which is utilized in this instructional exercise) so get the
datasheet of your engine to check the on which PWM period your Servo
engine works.
The recurrence of PWM (Pulse Width Modulated) sign can change
dependent on kind of servo engine. The significant thing here is the DUTY
RATIO of the PWM signal. In view of this DUTY RATION the control
hardware modify the pole.
As appeared in figure beneath, for the pole to be moved to 9o clock the
TURN ON RATION must be 1/18.ie. 1ms of ON schedule and 17ms of
OFF time in a 18ms sign.

For the pole to be moved to 12o clock the ON time of sign must be 1.5ms
and OFF time ought to be 16.5ms. This proportion is decoded by control
framework in servo and it alters the position dependent on it. This PWM in
here is created by utilizing MSP430. Become familiar with creating PWM
with MSP430 here.
Before Connecting Servo to MSP430, you can test your servo with the
assistance of this Servo Motor Tester Circuit. Likewise check our beneath
Servo activities:
Servo Motor Manage utilizing Arduino

Servo Motor Manage with Arduino Due

Servo Motor Interfacing with 8051 Microcontroller


Servo Motor Manage utilizing MATLAB

Servo Motor Manage by Flex Sensor

Servo Position Manage with Weight (Force Sensor)

Materials Required:

MSP430

SG90 servo

Male-Female wires

Circuit Diagram and Explanatin:


In MSP430, we have libraries which are predefined and PWM capacities
are composed as of now in these libraries in this way, we don't need to
stress over PWM values. You require to simply put the Angle by which you
require to pivot the pole and rest is worked by these libraries and
microcontroller.
Here, we are utilizing PIN 6 for example P1.4, which is PWM pin of
MSP430. Be that as it may, you can utilize any PIN. It isn't important to
utilize PWM pin for servo since all PWM functionalities are written in the
library itself.
Header document used to manage the servo is "servo.h".
We will utilize Energia IDE to compose our code. Code is straightforward
and straightforward. It is same concerning Arduino and can be found in the
Example menu. Complete code is given underneath, you can alter the code
according to your need and transfer it to MSP430
That is it!! We have interfaced a servo engine with a PIC Microcontroller,
presently you can utilize your own imagination and discover applications
for this. There are piles of tasks out there which utilize a servo engine.

void loop()
{
for(angle = 0; angle< 180; angle++) // goes from 0 degrees to 180
degrees
{ // in steps of 1 degree
Sg90servo.write(angle); // tell servo to go to position in variable
'angle’
delay(20); // waits 20ms for the servo to reach the position
}
for(angle = 180;angle>=1; angle--) // goes from 180 degrees to 0
degrees
{
Sg90servo.write(angle); // tell servo to go to position in variable
'angle'
delay(20); // waits 20ms for the servo to reach the position
}
}
18. HEARTBEAT WIDTH
MODULATION (PWM)
UTILIZING MSP430G2:
CONTROLLING
BRIGHTNESS OF LED
This instructional exercise is a piece of arrangement of MSP430G2
LaunchPad instructional exercises in which we are figuring out how to
utilize the MSP430G2 LaunchPad from Texas Instruments. So far we have
taken in the nuts and bolts of the board and have secured how to peruse
simple voltage, interface LCD with MSP430G2 and so on. Presently we
continue with the subsequent stage of finding out about PWM in
MSP430G2. We will do that by controlling the splendor of a LED by
fluctuating the potentiometer. So the potentiometer will be joined to a
simple pin of the MSP430 to peruse its simple voltage, thus it is prescribed
to know experience the ADC instructional exercise before continuing.

What is a PWM Signal?

Heartbeat Width Modulation (PWM) is a computerized signal which is


most usually utilized in charge hardware. This sign is set high (3.3v) along
with low (0v) in a predefined time along with speed. The time during which
the sign remains high is known as the "on schedule" and the time during
which the sign remains low is known as the "off time". There are 2
significant parameters for a PWM as talked about underneath:
Obligation pattern of the PWM:

The level of time wherein the PWM signal stays HIGH (on schedule) is
called as obligation cycle. In case the sign is consistently ON it is in 100%
obligation cycle and in case it is constantly off it is 0% obligation cycle.
Obligation Cycle =Turn ON schedule/(Turn ON time + Turn OFF time)

Recurrence of a PWM:

The recurrence of a PWM signal decides how quick a PWM finishes one
period. One Period is finished ON along with OFF of a PWM signal as
appeared in the above figure. In our instructional exercise the recurrence be
500Hz as it is the default esteem set by the Energia IDE.
There is plenty of uses for PWM flags continuously, yet to give you a
thought the PWM sign can be utilized to control servo Motors and can
likewise be changed over to Analog voltage which can control the brilliance
of the splendor of a LED. We should gain proficiency with somewhat about
how that should be possible.
Here are not many PWM models with other Microcontroller:

Creating PWM utilizing PIC Microcontroller with MPLAB


along with XC8

Servo Motor Control with Raspberry Pi


Arduino Based LED Dimmer utilizing PWM

Check all the PWM related activities here.

How to change over PWM sign to Analog voltage?

To PWM signs to Analog voltage we can utilize a circuit called RC channel.


This is a straightforward and most usually utilized circuit for this reason.
The circuit just remembers a Resistor along with a capacitor for
arrangement as appeared in the underneath circuit.

So what essentially occurs here is that when the when the Pulse Width
Modulation signal is high the capacitor energizes however the resistor and
when the Pulse Width Modulation signal goes low the capacitor releases
through the put away charge. In this way we will consistently have a steady
voltage at the yield which will be corresponding to the PWM obligation
cycle.
In the diagram appeared over, the Yellow shaded one is the Pulse Width
Modulation signal and the blue shading one is the yield simple voltage. As
should be obvious the yield wave won't be an unadulterated DC wave yet it
should work for our application. In case you need unadulterated DC wave
for other kind of use you should plan an exchanging circuit.

Circuit Diagram:
The circuit chart is quite straightforward; it simply has a potentiometer and
a Resistor and capacitor to frame a RC circuit and the Led itself. The
potentiometer is utilized to give a simple voltage dependent on which the
Pulse Width Modulation signal obligation cycle can be managed. The yield
of the pot is associated with Pin P1.0 which can peruse simple voltages. At
that point we require to deliver a PWM signal, which should be possible by
utilizing the pin P1.2, this Pulse Width Modulation signal is then sent to the
RC channel circuit to change over the Pulse Width Modulation signal into
Analog Voltage which is then given to the Light Emitting Diode.
It is essential to comprehend that not all pin on the MSP board can peruse
simple voltage or can produce PWM pins. The particular pins which can do
the particular assignments are appeared in the figure beneath. Continuously
utilize this as a direction to choose your pins for programming.

Collect the total circuit as appeared above, you can utilize a breadboard and
scarcely any jumper wires and effectively make the associations. When the
associations are done my board looked like as demonstrated as follows.
Programming the MSP for PWM signal:

When the equipment is prepared we can begin with our programming. The
primary thing in a program is to pronounce the pins that we are gonna to
utilize. Here we are gonna to utilize the pin number 4 (P1.2) as our yield pin
since it can create PWM. So we make a variable and relegate the pin name
with the goal that it's anything but difficult to allude to it later in the
program. Complete program is given toward the end.

int PWMpin = 4; //We are using the 4th pin on the MSP module as
PWM pin

Next we come into the arrangement work. Whatever code is composed here
will be executed just a single time, here we pronounce that we are utilizing
this fourth pin as a yield pin since PWM is yield usefulness. Note that we
have utilized the variable PWMpin here rather than the number 4 with the
goal that the code looks progressively important

void setup() {
pinMode(PWMpin,OUTPUT); //The PEMpin is set as Outptut

At long last we get into the circle work. Whatever we compose here gets
executed over along with over. In this program we require to peruse the
simple voltage and create a PWM signal appropriately and this needs to
happen over along with over. So first we should begin by perusing the
simple voltage from the pin A0 since we have associated with
potentiometer to it.
Here we are perusing the worth utilizing the AanalogRead work, this
capacity will restore an incentive from 0-1024 dependent on the estimation
of voltage applied to the pin. We at that point store this incentive to a
variable called "val" as demonstrated as follows

int val = analogRead(A0); // read the ADC value from pin A0

We require to change over the estimations of 0 to 1024 from the ADC to


estimations of 0 to 255 to offer it to the PWM work. For what reason would
it be a good idea for us to modify over this? I will tell that presently,
however for the time being simply recollect that we require to change over.
To change over one lot of qualities to another arrangement of qualities
Energia has a guide work like Arduino. So we convert the estimations of 0-
1204 to 0-255 and spare it back in the variable "val".

val = map(val, 0, 1023, 0, 255); //The ADC will give a value of 0-


1023 convert it to 0-255

Presently we have a variable estimation of 0-255 dependent on the situation


of the potentiometer. We should simply, utilize this incentive on the PWM
pin this should be possible utilizing the accompanying line.

analogWrite(PWMpin,val); //Write that value to the PWM pin.


How about we return to the inquiry why 0-255 is kept in touch with the
PWM pin. This worth 0-255 chooses the obligation pattern of the PWM
signal. For instance on the off chance that the estimation of sign is 0, at that
point it implies the obligation cycle is 0% for 127 it is half and for 255 it is
100% simply like what is appeared and clarified at the highest point of this
article.

Managing Brightness of Light Emitting Diode with Pulse Width


Modulation:

When you have comprehended the equipment and code, the time has come
to have a great time with the working of the circuit. Transfer the code to the
MSP430G2 board and turn the potentiometer handle. As you turn the
handle the voltage on pin 2 will change which will be perused by the
microcontroller and as indicated by the voltage the PWM signs will be
created on pin 4. The more noteworthy the voltage, the more prominent will
be the obligation cycle and the other way around.

This PWM signal at that point gets changed over into simple voltage to
sparkle a LED. The brilliance of the LED is straightforwardly
corresponding to the PWM signal obligation cycle. Aside from the LED on
the breadboard you can likewise see the smd LED (red shading) changing
its splendor like the breadboard drove. This is LED is likewise associated
with a similar pin, yet it doesn't have a RC organize so it is really
glimmering extremely quick. You can shake the board in a dim space to
check its glimmering nature.
That is in support of now people, we have figured out how to utilize PWM
flags on MSP430G2 board, in our next instructional exercise we will figure
out the fact that it is so natural to control a servo engine utilizing the
equivalent PWM signals.

Code
int PWMpin = 4; //We are using the 4th pin on the MSP module as PWM
pin
void setup() {
pinMode(PWMpin,OUTPUT); //The PEMpin is set as Outptut
}
void loop() {
int val = analogRead(A0); // read the ADC value from pin A0
val = map(val, 0, 1023, 0, 255); //The ADC will give a value of 0-1023
convert it to 0-255
analogWrite(PWMpin,val); //Write that value to the PWM pin.
}
19. STEP BY STEP
INSTRUCTIONS TO
UTILIZE ADC IN
MSP430G2 - MEASURING
ANALOG VOLTAGE
One basic element that is utilized in pretty much every installed application
is the ADC module. These Analog to computerized Converters can peruse
voltage from simple sensors like Temperature sensor, Tilt sensor, Current
sensor, Flex sensor and substantially more. So in this instructional exercise
we will figure out how to utilize ADC in MSP430G2 to peruse Analog
voltages utilizing the Energia IDE. We will interface a little potentiometer
to MSP board along with supply a differing voltage to an Analog pin, read
the voltage along with show it on the Serial Monitor.

Understanding the ADC module:

Trust me, it would barely take ten min to interface and program the
MSP430G2 to peruse Analog voltage. Yet, let us invest some energy in
understanding the ADC module in the MSP board so we will have the
option to utilize it adequately in the entirety of our up and coming ventures.
A microcontroller is a computerized gadget, which means it can see just 1's
and 0's. Be that as it may, in genuine world, nearly everything like
temperature, moistness, wind speed, and so on are simple in nature. So as to
connect with these simple modifies, the microcontroller utilizes a module
called Analog-to-Digital Converter. There are a wide range of sorts of ADC
modules accessible, the one utilized in our MSP is the SAR 8 channel 10-
piece ADC.
Progressive Approximation (SAR) ADC: The SAR ADC works with the
assistance of a comparator and some rationale discussions. This sort of
ADC utilizes a reference voltage (which is variable) and contrasts the
information voltage along with the reference voltage utilizing a comparator
and distinction, which will be an advanced yield, is spared from the Most
noteworthy piece (MSB). The speed of the correlation relies upon the Clock
recurrence (Fosc) on which the MSP is working.
10-piece Resolution: This ADC is a 8 channel 10 piece ADC. Here the
term 8 channel suggests that there are 8 ADC pins utilizing which we can
quantify simple voltage. The term 10-piece infers the goals of the ADC. 10-
piece implies 2 to the intensity of ten (210) which is 1024. This is the
quantity of test ventures for our ADC, so the scope of our ADC esteems
will be from 0 to 1023. The worth will increment from 0 to 1023 dependent
on the estimation of voltage per step, which can be determined utilizing the
underneath recipe

Note: By default in Energia the reference voltage will be set to Vcc (~3v),
you can shift the reference voltage by utilizing the analogReference()
alternative.
Likewise check how to interface ADC with different Microcontrollers:

How to Use ADC in Arduino Uno?

Interfacing ADC0808 with 8051 Microcontroller


Utilizing ADC Module of PIC Microcontroller

Raspberry Pi ADC Tutorial

Circuit Diagram:

In our past instructional exercise we previously figured out how to interface


LCD with MSP430G2 , now we are simply going to add a potentiometer to
the MSP430 to supply it a variable voltage and show the voltage esteem on
the LCD. On the off chance that you don't know about interfacing the LCD,
at that point fall back to the connection above and read through it, since I
will skirt the data to maintain a strategic distance from apology. The total
circuit chart of the venture is given beneath.
As should be obvious there are 2 potentiometers utilized here, one is
utilized for setting the complexity of LCD while the other one is utilized to
supply a variable voltage to the board. In that potentiometer one
extraordinary finish of the potentiometer is associated with the Vcc and the
opposite end is associated with Ground. The inside pin (blue wire) is
associated with the pin P1.7. This pin P1.7 will give a variable voltage from
0V (ground) to 3.5V (Vcc). So we require to program the pin P1.7 to peruse
this variable voltage and show it on the LCD.
In Energia, we have to know to which simple channel the pin P1.7 has a
place with? This can be found by alluding the beneath picture
You can view P1.7 nail to one side hand side, this pin has a place with A7
(Channel 7). Also, we can locate the individual channel number for
different pins too. You can utilize any pins from A0 to A7 for perusing
simple voltages here I have chosen A7.

Programming your MSP430 for ADC:

Programming your MSP430 to peruse simple voltage is straightforward. In


this program will peruse the simple of significant worth and ascertain the
voltage with that worth and afterward show both on the Liquid Crystal
Display screen. The total program can be found at the base of this page,
further underneath I am clarifying the program in bits to assist you with
seeing better.
We start by characterizing out LCD pins. These characterize to which pin of
MSP430 the LCD pins are associated. You can allude you association with
ensure that the pins are associated individually

#define RS 2
#define EN 3

#define D4 4

#define D5 5

#define D6 6

#define D7 7

Next, we incorporate the header document for the LCD show. This calls the
library which contains the code on how the MSP ought to speak with the
LCD. This library will be introduced in the Energia IDE as a matter of
course so you need not trouble including it. Likewise ensure the capacity
Liquid Crystal is called with the pin names that we simply characterized
previously.

#include <LiquidCrystal.h> //This librarey is insatlled by default


along with IDE

LiquidCrystal lcd(RS, EN, D4, D5, D6, D7); //Let the librarey know
how we have connected the LCD

Inside our arrangement() work, we would simply give an introduction


message to be shown in the Liquid Crystal Display screen. I am not getting
in much profound since we have as of now find out how to use LCD with
MSP430G2.

lcd.begin(16, 2); //We are using a 16*2 LCD display

lcd.setCursor (0,0); //Place the cursor at 1st row 1st column

lcd.print("MSP430G2553"); //Display a intro message


lcd.setCursor(0, 1); // set the cursor to 1st column 2nd row

lcd.print("Hello_world"); //Display a intro message

At long last, inside our boundless circle() work, we begin perusing the
voltage provided to the A7 pin. As we talked about as of now the
microcontroller is a computerized gadget and it can't peruse voltages level
straightforwardly. Utilizing SAR strategy the voltage level is mapped from
0 to 1024. These qualities are known as the ADC esteems, to get this ADC
esteem just utilize the accompanying line

int val = analogRead(A7); // read the ADC value from pin A7

Here the capacity analogRead() is utilized to peruse the simple estimation


of the pin, we have indicated A7 inside it since we have associated out
factor voltage to stick P1.7. At last we spare this incentive in a variable
called "val". The kind of this variable is whole number since we will just
get values going from 0 to 1024 to be put away in this factor.
The following stage is figure the voltage esteem from the ADC esteem. To
do this we have the accompanying formulae

Voltage = (ADC Value / ADC Resolution) * Reference Voltage

For our situation we definitely realize that the ADC goals of our
microcontroller is 1024. The ADC esteem is additionally found in the past
line and put away the variable called val. The reference voltage is
equivalent to the voltage at which the microcontroller is working. At the
point when the MSP430 board is controlled by means of USB link then the
working voltage is 3.6V. You can likewise gauge the working voltage by
using a multimeter over the Vcc and ground nail to the load up. So the
above recipe fits into our case as demonstrated as follows
float voltage = (float(val)/1024) * 3.6; //formulae to convert the
ADC value to voltage

You may be mistaken for the line glide (val). This is utilized to modifies the
variable "val" from int information type to "drift" information type. This
transformation is required on the grounds that just in case we get the
aftereffect of val/1024 in drift we can duplicate it 3.6. In case the worth is
gotten in whole number it will consistently be 0 and the outcome will
likewise be zero. When we have determined the ADC worth and voltage, all
that is left is to show the outcome on the Liquid Crystal Display screen
which should be possible by utilizing the accompanying lines

lcd.setCursor(0, 0); // set the cursor to column 0, line 0

lcd.print("ADC Val:");

lcd.print(val); //Display ADC value

lcd.setCursor(0, 1); // set the cursor to column 0, line 1

lcd.print("Voltage:");

lcd.print(voltage); //Display voltage

Here we have shown the estimation of ADC in the principal line and the
estimation of Voltage in the subsequent line. At long last we give a
postponement of 100 plant seconds and clear the LCD screen. This was the
worth will get refreshed for each 100 mils.

Testing your outcome!

At last, we come down to the pleasant part, which is trying our program and
messing with it. Simply make the associations as appeared in the circuit
outline. I have utilized a little breadboard to make my associations and
utilized jumper wires to interface the breadboard to MSP430. When the
associations are done mine resembled this underneath.
At that point transfer the program which is offered underneath to the
MSP430 board through the Energia IDE. You must have the option to see
the introduction message on the LCD, if not change the difference of the
LCD utilizing the potentiometer until you view clear words. Likewise, have
a go at squeezing the reset button. In the event that things fill in true to
form, at that point you ought to have the option to see the accompanying
screen.

Presently shift the potentiometer and you ought to likewise observe the
voltage showed in the LCD getting fluctuated. Allow us to confirm in the
event that we are estimating the voltage effectively to do that, utilization a
multimeter to quantify the voltage over the focal point of the POT and the
ground. The voltage showed on the multimeter ought to be near the worth
shown on the LCD as appeared in the image beneath.
That is it, we have figured out how to quantify simple voltage utilizing
ADC of MSP430 board. Presently we can interface numerous simple
sensors with our load up to peruse ongoing parameters. Expectation you
comprehended the instructional exercise and delighted in learning it. We
should do up for lost time in another instructional exercise of MSP430 with
another new theme.

Code
/*
* Reading Analog Voltage with MSP430 using Energia
*/
#define RS 2
#define EN 3
#define D4 4
#define D5 5
#define D6 6
#define D7 7
#include <LiquidCrystal.h> //This librarey is insatlled by default along with
IDE
LiquidCrystal lcd(RS, EN, D4, D5, D6, D7); //Let the librarey know how
we have connected the LCD
void setup() {
lcd.begin(16, 2); //We are using a 16*2 LCD display
lcd.setCursor (0,0); //Place the cursor at 1st row 1st column
lcd.print("MSP430G2553"); //Display a intro message
lcd.setCursor(0, 1); // set the cursor to 1st column 2nd row
lcd.print("-Hello_world"); //Display a intro message

delay(2000); //Wait for display to show info


lcd.clear(); //Then clean it
}
void loop() {
int val = analogRead(A7); // read the ADC value from pin A7
Voltage = (ADC Value / ADC Resolution) * Reference Voltage
float voltage = (float(val)/1024) * 3.6; //formulae to convert the ADC
value to voltage

lcd.setCursor(0, 0); // set the cursor to column 0, line 0


lcd.print("ADC Val:");
lcd.print(val); //Display ADC value
lcd.setCursor(0, 1); // set the cursor to column 0, line 1
lcd.print("Voltage:");
lcd.print(voltage); //Display voltage

}
20. INTERFACING LCD
WITH MSP430G2
LAUNCHPAD
This is the third instructional exercise in the arrangement of instructional
exercises where we are figuring out how to program the MSP430G2
LaunchPad utilizing the Energia IDE. In our past instructional exercise, we
find out how to manage the Digital Input and Output nails to our MSP
board. In this instructional exercise, we will find out how to interface a
LCD with the board so we can show valuable data.
The LCD that we are utilizing in this task is the most usually utilized 16×2
Dot grid LCD show a.k.an Alphanumeric Displays. A large portion of us
would have gone over this either through open PCOs or different hardware
ventures. A presentation like this will come in exceptionally helpful for our
future instructional exercises to show information and other troubleshooting
data. Interfacing this Liquid Crystal Display with MSP430 is simple,
because of the library accessible. So we should make a plunge!!

Materials Required:

MSP430G2 LaunchPad from Texas Instruments

16×2 Dot lattice LCD show

Associating wires
Energia IDE

Brief Intro to 16×2 Dot lattice LCD show:

As told before the Energia IDE gives an excellent library which makes the
interfacing a bit of cake and consequently it's not compulsory to know
anything about the showcase module. Be that as it may, would didn't it be
intriguing to show what we are utilizing!!
The name 16×2 infers that the showcase has 16 Columns and 2 Rows,
which together (16*2) structures 32 boxes. One single box would look like
this in the image underneath

A solitary box has 40 pixels (specks) with a lattice request of 5 Rows and 8
sections, these 40 pixels together structures one character. So also, 32
characters can be shown utilizing all the containers. Presently lets
investigate the pinouts.

The LCD has a sum of 16 Pins, as appeared above, they are divided into
four gatherings like as follows
Source Pins (1, 2 along with 3): These pins source the force and
differentiation level for the showcase
Control Pins (4, 5 along with 6): These pins sets/controls the registers in
the LCD interfacing IC (more this can be found in connect beneath)
Information/Command Pins (7 to 14): These pins give the information of
what data ought to be shown on the LCD.
Driven pins (15 and 16): These pins are utilized to sparkle the backdrop
illumination of LCD if necessary (discretionary).
Out of all these 16 pins, just 10 pins are to be utilized obligatory for the best
possible working of the LCD in the event that you need to find out about
these LCD show bounce to this LCD article.

Circuit Diagram and Connection:

The total circuit chart to interface a 16×2 Dot network LCD show with
MSP430G2 is demonstrated as follows.

One significant requirement while interfacing these 2 is their working


voltages. The Liquid Crystal Display show has a working voltage of +5V
while the MSP works just with 3.6V. Fortunate for us the information pin of
Liquid Crystal Display interface IC (HD44780U) has a large working
voltage of 2.7V to 5.5V. So we need to stress just over the Vdd (pin 2) of
the Liquid Crystal Display while the information pins can work even with
3.6V.
The MSP430G2 board of course doesn't give you a +5V pin, however by
we can do a little hack to get +5V from MSP430 utilizing the Universal
Serial Bus port. On the off chance that you investigate the Universal Serial
Bus port you can locate a terminal called TP1, this terminal will give us
+5v. We should simply to weld a little male header pin as appeared
underneath with the goal that we can associate it to our LCD show.

Note: Do not associate loads that may devour more than 50mA to this 5V
pin s it may broil your USB port.
In case you are not keen on binding basically utilize any +5V controlled
stock and force the LCD, considering all, ensure you associate the ground
of your capacity supply to the ground of the MSP board.
When you are finished with the +5V pin interfacing different pins are
practically direct. Since our equipment is prepared, how about we proceed
onward to the product part.

Programming MSP430 for LCD utilizing Energia:


The total program to interface a MSP430G2553 with LCD show is given
toward the finish of this page. The code can be arranged, transferred and
utilized in that capacity. In the accompanying passages, I will clarify how
the program functions.
Before we continue with clarification, we require to make a note of the pins
that we are utilizing. On the off chance that you investigate the circuit graph
above and the MSP430 pin-out chart beneath

You can infer that we have associated the LCD in accordance with the
accompanying table

LCD pin Connected


name to

Vss Ground

Vdd +5V USB


pin
Pin 2 of
Rs
MSP

R/W Ground

Pin 3 of
Enable
MSP

Pin 4 of
D4
MSP

Pin 5 of
D5
MSP

Pin 6 of
D6
MSP

Pin 7 of
D7
MSP

In view of this current how about we begin characterizing the LCD pins
utilized in our program. We will name each stick with a progressively
significant name so we can utilize it effectively later.

#define RS 2

#define EN 3

#define D4 4

#define D5 5

#define D6 6
#define D7 7

This just implies as opposed to calling pin 2 I can allude to it as RS


henceforth, comparably for each of the 6 pins.
The following stage is incorporate the LCD library. This library would be
introduced naturally when you introduced the Energia IDE. So simply
include it by utilizing the accompanying line

#include <LiquidCrystal.h>

The subsequent stage is to specify the pins to which the LCD is associated
with, as we have just named it utilizing the #define we can now basically
make reference to the names of the LCD pins. Ensure a similar request is
followed.

LiquidCrystal lcd(RS, EN, D4, D5, D6, D7);

Presently let us move into the void arrangement() work. There are such a
large number of sorts of LCD shows differing in size and nature, the one
that we are utilizing is 16*2 so how about we indicate that in our program

lcd.begin(16, 2);

To print something on the LCD we require to make reference to two things


in the program. One is the situation of the content can be referenced
utilizing the line lcd.setCursor() and other is the substance to print can be
referenced by lcd.print(). In this line we are setting the cursor to first line
and first segment.

lcd.setCursor (0,0);

Correspondingly, we can likewise


lcd.setCursor(0, 1); // set the cursor to 1st column 2nd row

Much the same as deleting a whiteboard in the wake of composing on it, a


LCD ought to likewise be eradicated once something is composed on it.
This should be possible by utilizing the underneath line

lcd.clear();

So the total void arrangement() capacity would look something like this.

void setup() {

lcd.begin(16, 2); //We are using a 16*2 LCD display

lcd.setCursor (0,0); //Place the cursor at 1st row 1st column

lcd.print("MSP430G2553"); //Display a intro message

lcd.setCursor(0, 1); // set the cursor to 1st column 2nd row

lcd.print("Hello_world"); //Display a intro message

delay(2000); //Wait for display to show info

lcd.clear(); //Then clean it

Next, inside our void circle() work, we should keep augmenting a number
for each 500ms and show the number in the LCD. This number tests and is
instated to 1 as demonstrated as follows

int test =1;


To make a defer we can utilize the inbuilt capacity delay(). We need to
specify how much time we need the deferral to happen. For our situation, I
have utilized 500ms as demonstrated as follows

delay(500);

Increasing a variable should be possible by test++, the rest all are as of now
clarified. The total code inside the void circle is demonstrated as follows

void loop() {

lcd.print("LCD with MSP"); //Display a intro message

lcd.setCursor(0, 1); // set the cursor to column 0, line 1

lcd.print(test); //Display a intro message

delay(500);

lcd.clear(); //Then clean it

test++;

16x2 LCD with MSP430G2:

When your equipment and code is prepared, basically associate your board
the PC and transfer the code as we did in instructional exercise one. When
the code is transferred you should see the presentation demonstrating the
accompanying.
Following two seconds, the showcase screen will change from arrangement
to circle and begin augmenting the variable and show on the screen as
demonstrated the underneath picture.

Feel free to have a go at changing what's being shown on the LCD and play
with it. Expectation you comprehended the instructional exercise and got
the hang of something valuable structure it.
Code
/*
* Interfacing 16*2 LCD with MSP430G2553 in 4-bit mode using Energia
*/
#define RS 2
#define EN 3
#define D4 4
#define D5 5
#define D6 6
#define D7 7
#include <LiquidCrystal.h> //This librarey is insatlled by default along with
IDE
LiquidCrystal lcd(RS, EN, D4, D5, D6, D7); //Let the librarey know how
we have connected the LCD
void setup() {
lcd.begin(16, 2); //We are using a 16*2 LCD display
lcd.setCursor (0,0); //Place the cursor at 1st row 1st column
lcd.print("MSP430G2553"); //Display a intro message
lcd.setCursor(0, 1); // set the cursor to 1st column 2nd row
lcd.print("-Hello_world"); //Display a intro message
delay(2000); //Wait for display to show info
lcd.clear(); //Then clean it
}
int test =1;
void loop() {
lcd.print("LCD with MSP"); //Display a intro message
lcd.setCursor(0, 1); // set the cursor to column 0, line 1
lcd.print(test); //Display a intro message
delay(500);
lcd.clear(); //Then clean it
test++;

}
THANK YOU

You might also like