0% found this document useful (0 votes)
44 views46 pages

Assignmnent Isanka

This document describes three projects implemented using the Arduino platform: a traffic light system, a Morse code encoder and decoder, and encrypted communication between two XBee modules. The traffic light system uses LEDs and buttons to simulate traffic lights, while the Morse code projects encode and decode text messages into Morse code signals. The XBee communication establishes a wireless encrypted connection between a coordinator and endpoint module to transmit data. Diagrams, code snippets, and descriptions of the hardware and software design are provided for each project. The document also acknowledges the module leader and provides tables of contents, figures, and a list of resources used.

Uploaded by

Dilshan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views46 pages

Assignmnent Isanka

This document describes three projects implemented using the Arduino platform: a traffic light system, a Morse code encoder and decoder, and encrypted communication between two XBee modules. The traffic light system uses LEDs and buttons to simulate traffic lights, while the Morse code projects encode and decode text messages into Morse code signals. The XBee communication establishes a wireless encrypted connection between a coordinator and endpoint module to transmit data. Diagrams, code snippets, and descriptions of the hardware and software design are provided for each project. The document also acknowledges the module leader and provides tables of contents, figures, and a list of resources used.

Uploaded by

Dilshan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 46

The School of Technology

BSc(Hons) in Computer Networks

(Batch 004)

Applied Computer Systems Engineering

5CC002

By

W.A.I Dilshan

(UoW ID: 1918298)

Module Leader: Mr.Rajeewa

1
Acknowledgment

I wish to express my appreciation and deep regards to our guide Mr.Rajjewa


for his exemplary guidance, monitoring and constant encouragement throughout the
course. Furthermore, I would like to thank my colleagues who extended their great support
during assignment. This assignment would not have been a success without the
cooperation

1
Abstract
This document proposes the design and development of three systems which using the Arduino
platform. Projects developed due to the requirement of gaining knowledge and as a Portfolio
exercises. Portfolios are lead to understand basic coding and hardware fixing to developing
encrypted communication using Xbee modules. At the beginning following the assignment
guidance developed the traffic light system, then impalement Morse code communication
method with the resources in internet. Each project incrementally helps to get hand on
awareness of Arduino platform. Those are Traffic Light System, Morse Encoder / Decoder and
encrypted communication using XBee

Xbee communication using Arduino platform possible develop up to


industrial and home applications but the traffic light and Morse code tent appear some errors
due to low accuracy of hardware components. Push button bouncing error leads to appear
misleading outputs. If the experiments configured on Rasbari platform with more accurate
hardware equipment, outcome will be more reliable.

2
TABLE OF CONTENTS

Acknowledgment ………………………………………………………………... 01
Abstract ……….………………………………………………………………... 01
Table of Figures …………………………………………………………………. 05
1.0 Apparatus used in portfolios ………………………………………………. 06
1.1 Arduino Uno ………………………………………………………………... 06
1.2 Liquid Crystal Display (LCD) …………………………………………… 07
1.3 Buzzer …….……………………………………………………………….. 08
1.4 XBee module.…………………………………………………………….. 09
2. Implementation of Traffic Light…………………………………………… 11
2.1 Aims ……….………………………………………………………………. 11
2.2 Objectives …………………………………………………………………... 11
2.3 Apparatus…….……………………………………………………………… 11
2.4 Operation of 1st Part……………………………………………………….. 12
2.4.1 Flow Chart………………………………………………………… 12
2.4.2. Design and Implementation……………………………………... 13
2.4.3 Code ….…………………………………………………………… 14
2.4.4 Operation of code.………………………………………………… 14
2.5 Operation of 2nd Part………………………………………………………… 15
2.5.1 Flow Chart ………………………………………………………… 16
2.5.2. Design ……………………………………………………………… 16
2.5.3 Code ……….……………………………………………………… 17
2.5.4 Operation of code …………………………………………………… 18
2.6 conclusion ……….…………………………………………………………… 19
2.7 Further Implementation ……………………………………………………… 19
3.0 Implementation of Morse Encoder/Decoder………………………………… 20
3.1 Aims ……….………………………………………………………………... 20
3.2 Objectives ……….…………………………………………………………… 20
3.3 Apparatus……….……………………………………………………………… 20
3.4 Flowchart ……….…………………………………………………………… 21
3.4.1 Encoder .……………………………………………………………. 23
3.4.2 Decoder .……………………………………………………………. 23
3.5 Design and Implementation………………………………………………... 23
3.5.1 Encoder Design.……………………………………………………. 23
3.5.2 Decoder Design.……………………………………………………. 24
3.5.3 Morse code and symbols………………………………………….. 25
3.6 Code ……….………………………………………………………………... 26
3.6.1 Encoder Code.………………………………………………….…. 26
3.6.2 Decoder Code.…………………………………………………...…. 27
3.7 Operation of code ……….…………………………………………………... 28
3.7.1 Operation of encoder coding……………………………………….. 28
3.7.2 Operation of decoder coding……………………………………….. 28
3.8 conclusion ……….…………………………………………………………….. 29
3.9 Further Implementation.………………………………………………………. 29

3
4.0 Xbee Module Operations …………………………………………………….. 30
4.1 Aims …………………..………………………………………………………… 30
4.2 Objectives …………………..……………………………………………………. 30
4.3 Apparatus …………………..……………………………………………………... 30
4.4 Flowchart …………………..……………………………………………………... 31
4.4.1 Coordinator…………………………………………………………………
32
4.4.1 End Point…………………………………………………………………… 32
4.5 Design …………………..………………………………………………………… 33
4.5.1 Coordinator ………………………………………………………………... 33
4.5.2 End Point…………………………………………………………………… 34
4.6 Algorithm…………..……………………………………………………………….. 36
4.7 Code …………………..……………………………………………………………. 37
4.7.1 Coordinator ………………………………………………………………… 37
4.7.2 End Point ………………………………………………………………….. 37
4.8 Operation of code ………..………………………………………………………… 39
4.8.1 Coordinator ………………………………………………………………... 39
4.8.2 End Point…………………………………………………………………… 39
4.9 conclusion ……………..…………………………………………………………… 40
4.10Further Implementation…..………………………………………………………... 41
5.0 Resources ……………..…………………………………………………………… 42

4
TABLE OF FIGURES

Figure 01- Arduino UNO board …………………………………………... 06


Figure 02- LCD Display…………………………………………………… 07
Figure 03-LCD Wiring Diagram ………………………………………….. 08
Figure 04- Buzzer…………………………………………………………. 08
Figure 05-Xbee module…………………………………………………… 09
Figure 06-Xbee module basement…………………………………………. 10
Figure 07- Flow chart 01…………………………………………….. …… 12
Figure 08- LED Connection……………………………………………….. 13
Figure 09-LED……………………………………………………………... 13
Figure 10-Flowchart 02……………………………………………………. 16
Figure 11-Flowchart 03…………………………………………………… 21
Figure 12-Flowchart 04……………………………………………………. 22
Figure 13 -Implementation Morse Code………………………………….. 23
Figure 14 -Connections…..……………………………………………….. 23
Figure 15- Implementation Decoder………………………………………. 24
Figure 16 - Diagram………………………………………………………. 24
Figure 17- Characters …………………………………………………….. 25
Figure 18 -Xbee TX Flowchart …………………………………………… 31
Figure 19 - Xbee RX Flowchart ………………………………………… . 32
Figure 20- Connection Diagram ………………………………………….. 33
Figure 21- Xbee Coordinator …………………………………………….. 33
Figure 22- Xbee End point.……………………………………………….. 34
Figure 23 -Coordinator XCTU. …..……………………………………….. 34
Figure 24 -Receiver XCTU……………………………………………….. 35

5
1.Apparatus used in portfolios

1.1 Arduino Uno

Arduino is an open source electronics platform based on easy-to-use hardware and


software. Arduino boards can read input. Arduino board can be sending a series of instructions to
the microcontroller on the board. Arduino is the programming language base writing and Arduino
software IDE based processing. In This project use Arduino Uno board it consists of USB
interface, 14 digital I/O pins, 6 analog pins, and Atmega328 microcontroller. It also supports
serial communication using Tx and Rx pins.
The connection descriptions are mentions in Figure 01

Figure 01- Arduino UNO board

6
1.2 Liquid Crystal Display (LCD)

LCDs are providing cost effective way to put a text output unit for a
microcontroller. LCD display commonly use 16 * 2 and 16 *4. In this project carryout by 16 * 2
display. It has 2 lines and can display 16 characters on each line. When it is interfaced with the
microcontroller, can scroll the messages with software to display information which is more
than 16 characters in length.
The LCD is a simple device to use but the internal details are complex. Most of the 16x2
LCDs use a Hitachi HD44780 or a compatible controller. A microcontroller is present inside a
Liquid crystal display. The Display Controller takes commands and data from a external
microcontroller and drivers the LCD panel. It takes a ASCII value as input and generate a patter
for the dot matrix.

The port descriptions are mentions in Figure 02

Figure 02- LCD Display

7
The wiring diagram mention in Figure 03

Figure 03-LCD Wiring Diagram

1.3 Buzzer
In Arduino implementations Buzzer use to generate the sounds. In here Buzzer applied to make
the Beep tone according to the Morse encoder.

8
Figure 04- Buzzer

1.4 XBee module

XBee is a product name not a standard. XBee is a wireless communication module


that Digi built to the 802.15.4/ ZigBee standard. ZigBee is a standard defined by the IEEE ( Institute of Electrical

and Electronics Engineers). ZigBee aim to have lower data rate compared to Bluetooth, at 250Kbps.
More importantly, ZigBee aims for lower power applications which can operation on non-rechargeable
battery and it can connect to more nodes. While Bluetooth only offers 8 devices connection. ZigBee
designed for control and monitor while Bluetooth for cable replacement. ZigBee uses RF (Radio
Frequency) to communicate. There are 3 frequencies available, 2.4GHz, 915MHz & 868MHz.

The module connects to the Arduino board using a connecter and XTCU application use to
configure and communicate with each other modules in network.

9
Figure 05 mention the XBee module.

Figure 05- Xbee module

Figure 06 mention basement for connect the module and Arduino board.

10
Figure 06-Xbee module basement

2.Implementation of Traffic Light

2.1 Aims

 To design Light System with three bulbs


 To design traffic Light system

2.2 Objectives

 Get awareness about the basic Arduino coding.

11
 Develop an Arduino code which is integration with above systems.
 Design a hardware units which can achieve required Aims.

2.3 Apparatus
 Arduino Uno board
 3 Light Emitting Diodes (LED) Red, Yellow, Green Colors
 Connecting jumpers & breadboard

2.4 Operation of 1st Part

Build a circuit with three LEDs, a red, a yellow and a green. Create a sketch that
ripples through the LEDs such that, In order to the red LED ONLY lights up for half a second,
then Yellow after that Green LED lights up for half a second.

This loop starts again.

2.4.1 Flow Chart

12
Figure 07-Flow chart 01

2.4.2 Design and Implementation


Circuit was connected using the bread board as below Figure 08. Light Emitting
Diodes (LED) were connected in separate columns in bread board and column ground
vertical line. Voltage was supplied to each LED separately. Resistors did not apply
because of LEDs had been capable of working under 5v. Male to male connecting
jumpers were used to plug Arduino board and LEDs

13
14
Figure 08- LED Connection

Figure 09- LED

2.4.3 Code
int LED1 = 6; // 1 DIGITAL PIN-OUT
int LED2 = 8; // 2 DIGITAL PIN-OUT
int LED3 = 9; // 3 DIGITAL PIN-OUT
int DL=500;
void setup() {
pinMode(LED1 , OUTPUT);
pinMode(LED2 , OUTPUT);
pinMode(LED3 , OUTPUT);}
void loop() {
for ( int t=1; t<=1; t=t+1)
{ digitalWrite(LED1,HIGH); //start for loop
delay (DL);
digitalWrite(LED1,LOW);
delay (DL); }
{ //start for loop
digitalWrite(LED2,HIGH);
delay (DL);
digitalWrite(LED2,LOW);
delay (DL);}
{digitalWrite(LED3,HIGH);
delay (DL);
digitalWrite(LED3,LOW);
delay (DL);
}}

15
2.4.4 Operation of Code

1. Initialization of the code


This part will setup pins in coding and the declarations that used in the coding.
Here used Digital Pin 6,8,9 as output pins and DL delay of 500 milliseconds

int LED1 = 6; // 1 DIGITAL PIN-OUT


int LED2 = 8; // 2 DIGITAL PIN-OUT
int LED3 = 9; // 3 DIGITAL PIN-OUT
int DL=500

2. Setup Part of the code


It will run only onece , it will define the input and output, In here LED pins used as
outputs

void setup() {
pinMode(LED1 , OUTPUT);
pinMode(LED2 , OUTPUT);
pinMode(LED3 , OUTPUT);}
3. Loop part of the coding

This will repeat until the for loop exceed the condition t<=1, The increment will take
according to the t=t+1. According to the workshop bulbs are ON and OFF times has
defined. Each bulb ON and OFF time in 500 milliseconds.

void loop() {
for ( int t=1; t<=1; t=t+1)
{ digitalWrite(LED1,HIGH); //start for loop
delay (DL);
digitalWrite(LED1,LOW);
delay (DL); }
{ //start for loop
digitalWrite(LED2,HIGH);
delay (DL);
digitalWrite(LED2,LOW);
delay (DL);}
{digitalWrite(LED3,HIGH);
delay (DL);
digitalWrite(LED3,LOW);
delay (DL);
}}

16
2.5 Operation of 2nd Part

Build a circuit for traffic lights, with three LEDs Red, Amber, and Green.
The traffic light sequence is Red, Red and Amber, Green, Amber.
This loop starts again.

2.5.1 Flow Chart

17
Figure 10- Flowchart 02

2.5.2 Design
Circuit was connected using the bread board and the connecting jumpers.
Hardware connection was kept as above part, and few changes were done to code for get the
required output.

2.5.3 Code

18
int LED1 = 6; // RED CONFIG DIGITAL PIN-OUT
int LED2 = 8; // AMBER CONFIG DIGITAL PIN-OUT
int LED3 = 9; // GREEN CONFIG DIGITAL PIN-OUT
int DL1=3000;
int DL2=500;

void setup() {
pinMode(LED1 , OUTPUT);
pinMode(LED2 , OUTPUT);
pinMode(LED3 , OUTPUT);
}
void loop() {
for ( int t=1; t<=1; t=t+1)
{ //start for loop
digitalWrite(LED1,HIGH); //RED LIGHT ON
delay (DL1);
digitalWrite(LED1,LOW);
delay (DL2);
}
{ //start for loop
digitalWrite(LED1,HIGH); //RED LIGHT ON
digitalWrite(LED2,HIGH);// AMBER LIGHT ON
delay (DL2);
digitalWrite(LED1,LOW);
digitalWrite(LED2,LOW);
delay (DL2);
}
{
digitalWrite(LED3,HIGH);// GREEN LIGHT ON
delay (DL1);
digitalWrite(LED3,LOW);
delay (DL2);
}
{
digitalWrite(LED2,HIGH);// AMBER LIGHT ON
delay (DL2);
digitalWrite(LED2,LOW);
delay (DL2);
}
}

2.5.4 Operation of Code

19
1 Initialization of the code
This part will setup pins in coding and the declarations that used in the coding.
Here used Digital Pin 6,8,9 as output pins and there are two delays are available.
DL1 delay of 3000 milliseconds and DL2 500 milliseconds.

int LED1 = 6; // RED CONFIG DIGITAL PIN-OUT


int LED2 = 8; // AMBER CONFIG DIGITAL PIN-OUT
int LED3 = 9; // GREEN CONFIG DIGITAL PIN-OUT
int DL1=3000;
int DL2=500;

2. Setup Part of the code


It will run only onece , it will define the input and output, In here LED pins used as
outputs

void setup() {
pinMode(LED1 , OUTPUT);
pinMode(LED2 , OUTPUT);
pinMode(LED3 , OUTPUT);}

3. Loop part of the coding

Practical in Traffic light system seconds of operation Green, Amber & Red are different.
DL1,DL2 basically used here short and long delay times.This will repeat until the for loop
exceed the condition t<=1, The increment will take according to the t=t+1.

void loop() {
for ( int t=1; t<=1; t=t+1)
{ //start for loop
digitalWrite(LED1,HIGH); //RED LIGHT ON
delay (DL1);
digitalWrite(LED1,LOW);
delay (DL2);
}

2.6 Conclusion

20
In summary this lab was helped to observe basics of Arduino coding. Mainly for identify
which part contribute to setup and operate as loop in the operation. In this Traffic light
scenario can use to one-way vehicles control with the pedestrian crossing. It hasn’t
mentioned clearly time delays for each operation. If it is possible to modulate the code to
operate this loop in only rush hours that would be more effective otherwise vehicles would
have to wait without any traffic or pedestrians.

2.7 Further Implementations


Here loop function carried with FOR LOOP and delay timers. Portfolio guided to make
traffic light using the delay. It has developed up to one-way traffic light but in practical
scenarios operations may be having to developed to 3,4 ways traffic lights.in that
situations delay timers have to programed. There should be a 2 or 3 seconds of time gap in
which one part of ending and startup of other, it will lead to avoid accidents which can
occur due to human mistakes

This for loop, delay can have used as many as industrial operations which operate in
production lines combining more sensors, contactors, motors and actuators. Mostly in
production lines conveyer belt operations timers are most important. But the limited input,
output and not possible to communicate industrial protocols such as PPI, MPI, Profibus
leads to Arduino swap PLC in industrial operations.

3 Implementation of Morse Encoder/ Decoder


21
3.1 Aims

 To design Morse code Encoder with Buzzer sound


 To design Morse decoder with press button and LCD
 To identify Morse code characters

3.2 Objectives

 Get awareness about how serial monitor and LCD monitor operate in Arduino platform.
 Develop an Arduino code which is possible to encode and decode Morse code.
 How to connect LCD display without i2c converter using variable resistor
 To decode the character according to buzzer sound or request as per lecture using push
button

3.3 Apparatus

 Arduino Uno board


 LED Display, Resistors, Variable resistor
 Buzzer & Resistors
 Connecting jumpers & breadboard
 Push Button

3.4 Flowchart

22
3.4.1Encoder

Figure 11-Flowchart 03

23
3.4.2 Decoder

Figure 12--Flowchart 04

24
3.5 Design and Implementation
3.5.1 Encoder Design

Figure 13- Implementation Morse code

Figure 14- Connections

25
3.5.2Decoder Design

Figure 15- Implementation Decoder

26
Figure 16- Diagram

In this portfolio setup of initial connection for LCD display was completed according to
the given diagram. Encoder and Decoder setup was completed as above figures. 5V
power supply was given to power up LCD. Buzzer pin was separately connected to
Arduino board. In decoder side, push button was connected using voltage divider mode.
This voltage dividing operation was done by using a resistor.

3.5.3Morse code symbols

Figure 17- Characters


Morse code is a communications language created by Samuel Morse
and Alfred Vail originally to be used with the telegraph in the past. Each letter of the alphabet is
made up of combinations of dots and dashes that were originally sent over telegraph wires or
by radio waves from one place to another.
Morse is the earliest type of digital communications, as the code is made solely from Ones and
Zeros (ons and offs). It was the only way to rapidly communicate over very long distances before

27
voice communications and two-way radios were able to do the job better.
3.6 Code for Encoder and Decoder

3.6.1 ENCODER CODE


int ledPin = 8; //For BUZZER
#include <LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
char c[33];
// Letters represtation in morse code
char* letters[] = { ".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-",
".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--.." };
// Numbers represtation in morse code
char* numbers[] = {"-----", ".----", "..---", "...--", "....-", ".....", "-....", "--...", "---..", "----."};
// Delay between seperate of dots
int dotDelay = 200;
void setup() {
pinMode(ledPin, OUTPUT); // for BUZZER
Serial.begin(9600); // use serial display
lcd.begin(16,2); // lcd dispaly }
void loop() {
char ch;
if (Serial.available()) {
lcd.clear();
int i=0;
while (Serial.available()>0){
ch = Serial.read(); // read the serial monitor
if (ch >= 'a' && ch <= 'z') // For Simple letters a to z
{ LSequence(letters[ch - 'a']);}
else if (ch >= 'A' && ch <= 'Z') // For capital letters A to Z
{ LSequence(letters[ch - 'A']);}
else if (ch >= '0' && ch <= '9') // For numbers
{LSequence(numbers[ch - '0']); }
else if (ch == ' ') // none of the any , make delay
{ delay(dotDelay * 4); }}}}
void LSequence(char* sequence) //Sequences to flashed by parsing the seqeunce of letters read by the serial monitor
{ int i = 0;
while (sequence[i] != NULL) // while there are still characters keep going through each one
{ DotOrDash(sequence[i]);
i++; } // increment by one until end of characters
delay(dotDelay * 3); // gap between letters
}
void DotOrDash(char dotOrDash) // checks dot or dash

{ lcd.print(dotOrDash);
delay(dotDelay); // To LCD print

{digitalWrite(ledPin, HIGH); // To BUZZER opertatiom


if (dotOrDash == '.')
{ delay(dotDelay);}
else

28
{delay(dotDelay * 3); }
digitalWrite(ledPin, LOW); delay(dotDelay);}}
3.6.2 Decoder Code

unsigned long signal_len,t1,t2; //time for which button is pressed


int inputPin = 6; //input pin for push button
String code = ""; //string in which one alphabet is stored
void setup()
{ Serial.begin(9600);
pinMode(inputPin, INPUT_PULLUP); //internal pullup resistor is used to simplify the circuit
}
void loop()
{NextDotDash:
while (digitalRead(inputPin) == HIGH) {}
t1 = millis(); //time at button press
while (digitalRead(inputPin) == LOW) {}
t2 = millis(); //time at button release
signal_len = t2 - t1; //time for which button is pressed
if (signal_len > 50) //to account for switch debouncing
{ code += readio(); //function to read dot or dash }
while ((millis() - t2) < 500) //if time between button press greater than 0.5sec, skip loop and go to next
alphabet
{ if (digitalRead(inputPin) == LOW)
{ goto NextDotDash; }
convertor(); //function to decipher code into alphabet }
char readio()
{ if (signal_len < 600 && signal_len > 50)
{return '.'; //if button press less than 0.6sec, it is a dot }
else if (signal_len > 600)
{ return '-'; //if button press more than 0.6sec, it is a das }}
void convertor()
{ static String letters[] = {".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--", "-.", "---", ".--.",
"--.-",
".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--..", "E" };
int i = 0;
if (code == ".-.-.-")
{Serial.print("."); //for break }
else
{while (letters[i] != "E") //loop for comparing input code with letters array
{ if (letters[i] == code)
{Serial.print(char('A' + i));
break; }
i++; }
if (letters[i] == "E")
{ Serial.println("<Error>"); //if input code doesn't match any letter, error} }
code = ""; //reset code to blank string}

29
3.7Operation of Code
3.7.1 Operation of Encoder Coding
1. Define Arduino libraries for LCD Display
2. In void setup
Define Morse code characters for each letter and number
Define Buzzer pin to output and communication start with serial monitor

3. In void loop
Define input latter as “I” and check the condition which category the “l” should include in to A
Simple letter, capital letter, Number or else Ignore

4.Appling Void LSequence and While loop check remaining letters that user input and convert in to the
Morse code
5.Then print the converted Morse code dot or dash on LCD and Generate the Buzzer sound according to
dot or dash

3.7.2 Operation of Decoder Coding

1.Define Arduino libraries for LCD Display, Define Switch pin to input signal
2.In void setup
Communicate start with Serial monitor and LCD
3.In void loop
Define t1 and t2 times and calculate signal length by t2-t1. According to conditions if time gap
below 50 ignore
Define LCD display to show all characters that input by press button
4.Char radio
define the time gap to identify dot or dash. If time length below 600 milliseconds that will be a
dot. If time length above the 600 milliseconds that will be a dash.
5.Void convertor
Define i = 0 and select the letter using ASCII values. Input characters has matched with Letters by
static string, identified letters will print on LCD
if there is any wrong input that will indicate as wrong

30
3.8Conclusion
In the practical, separately developed the both encoder and decoder. Encoder side use to transmit
the message using LCD monitor and Buzzer sounds, Decoder side code decoded in to Letters by
pressing the push button according to characters.
There were some features that tried to be added in decoder side. If mic can identify the sound of
Buzzer, it will decode the Morse message without push button. Although in the implementation
mic not able to properly detect sound lengths and gaps.
Another main problem was bouncing issue in push button, implementing push button to input the
Morse code. Push button was unable to input the signal properly.
All switches are not created equal, and some will fluctuate between both state LOW to HIGH
when pressing the switch and this can introduce multiple detected presses on the Arduino.
To control this issue debouncing was implemented in code. It will avoid the messages that
below 50 milliseconds.

Internal Pull-up resistor was used to ignore the delay from when the button is pressed until the
state of the pin actually changes. And stop the pin’s value will seem to randomly fluctuate from
HIGH to LOW

3.9Further Implementations

At the invented period of Morse code use to communicate with Navy, Pilots and Morse Code
was used during World War II. SOS signal use to communicate through Morse code when they
are in trouble. SOS mean international code to help.

There are many things that have Morse code used. SOS signal can flash using flashlights, smoke,
mirrors. Radio operators use Morse code to communicate when they are hosting contest to
communicate fast.
Morse Code has also been used as an alternative form of communication for people with
disabilities or whom have their abilities to communicate imparied by stroke, heart attack, or

31
paralysis.  It remains popular among amateur radio operators. 

4.Xbee Module Communication


4.1 Aims

 To Setup wireless communication using Xbee


 To get awareness about XCTU operation
 To build encrypted communication between two device

4.2 Objectives

 Develop wireless communication between two Xbee devices


 Observe transmitted message from LCD display at remote location
 Using XCTU software Xbee modules should be configured to communicate between
devices, it can be only two end points, mesh or star network

4.3 Apparatus

32
 Two Arduino boards
 Two Xbee modules
 LCD display with i2c converter
 Connecting jumpers

4.4 Flow Chart


4.4.1 Coordinator (Transmitter)

33
Figure 18-Xbee TX Flowchart
4.4.2 End Point (Receiver)

34
Figure 19-Xbee RX Flowchart

4.5 Design

35
Xbee module connected to Arduino board as below diagram

Figure 20- Connection Diagram


4.5.1 Coordinator

Figure 21- Coordinator


4.5.2 End Point

36
Figure 22- End point

Figure 23- Coordinator XCTU

37
Figure 24- End point XCTU

38
4.6 Algorithm
Caesar Cipher
The Caesar Cipher technique is one of the earliest and simplest method of encryption technique.
Each letter of a given text is replaced by a letter some fixed number of positions down the
alphabet.
Example with a shift of 1, A - B, B - C.
In this method to cipher a given text we need an integer value, known as shift which indicates the
number of position each letter of the text has been moved down.
The encryption can be represented using modular arithmetic by first transforming the letters into
numbers, according to the scheme, A = 0, B = 1,…, Z = 25.
In coding it can achieve by below equation

 for (int i=0;i<text.length();i++)


    {
        // apply transformation to each character
        // Encrypt Uppercase letters
        if (isupper(text[i]))
            result += char(int(text[i]+s-65)%26 +65);
  
    // Encrypt Lowercase letters
    else
        result += char(int(text[i]+s-97)%26 +97);
    }
 

39
4.7 Code
4.7.1 Coordinator
#include <SoftwareSerial.h>
String result ="";
String text="";
String FN="";
int s =0;
SoftwareSerial cipertx(2,3);

void setup() {
Serial.begin(9600);
cipertx.begin(9600);
}
void loop() {
ENCODE();
}
void ENCODE(){
Serial.println("Enter Plain Text.");
while (Serial.available()==0){}
text = Serial.readString();
delay(500);
Serial.println("Enter Key.");
while (Serial.available()==0){}
s = Serial.parseInt();
int n =text.length();
String result ="";
for (int i=0;i<n;i++){
if (isupper(text[i])){
result += char(int(text[i]+s-65)%26 +65);
FN = result;}
else if(isWhitespace(text[i])){
result += char(int(text[i])); }
else
result += char(int(text[i]+s-97)%26 +97);
FN = result; }
cipertx.print(FN);
}

4.7.2 End Point


#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SoftwareSerial.h>
LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
String text1="";
String FN1="";
int s =0;
int p =0;
SoftwareSerial cipertx(2,3);

40
void setup()
{Serial.begin(9600);
cipertx.begin(9600);
lcd.init(); // initialize the lcd
lcd.init();
lcd.backlight(); // Print on LCD.
lcd.setCursor(0,0);
lcd.print("Begining....");}

void loop()
{while (cipertx.available()==0){}
text1 = cipertx.readString();
lcd.setCursor(0,0);
lcd.print("Encrypted Text ");
lcd.setCursor(0,1);
delay(50);
Serial.print("Encrypted Text ");
Serial.println(text1);
lcd.print(text1);
delay(50);
DECODE(); }

void DECODE(){
Serial.println("Key to show original text.");
while (Serial.available()==0){}
p = Serial.parseInt();
delay(500);
int n =text1.length();
String result ="";
for (int i=0;i<n;i++){
if (isupper(text1[i])){
result += char(int(text1[i]-p-65)%26 +65);
FN1 = result;}
else if(isWhitespace(text1[i])){
result += char(int(text1[i])); }
else
result += char(int(text1[i]-p-97)%26 +97);
FN1 = result; }
Serial.print(FN1);
delay(50);
lcd.setCursor(0,0);
lcd.clear();
lcd.print("Original Text.");
lcd.setCursor(0,1);
lcd.print(FN1);}

41
4.8 Operation of Code
4.8.1 Coordinator
1.SoftwareSerial library define to communicate between Xbee module

2.Define string and cha for variables

3.Void Setup

Serial.begin use to communicate with serial display

Cipertx.begin use to communicate with serial in confidentially

4.Void Encode

Beginning by Enter the Plain Text on display serial monitor

Then enter the key

5.Then considering length of text "n" convert the text in to cipher text

It separately considers Capital letters, Space and simple letters using if condition

4.8.2 End Point

1.SoftwareSerial library define to communicate between Xbee module, Define libraries for i2c converter
and LCD display

2.Define string, integer and cha for variables

3.Void Setup
Serial.begin use to communicate with serial display
Cipertx.begin use to communicate with serial in confidentially
Display on LCD as beginning

4.Void Loop
Display Encrypted text after received to end point

5.Void Decode
Display as asking the key to decrypt the encrypted message, then enter the key
After that consider length of text "n" of cipher text.
It separately considers Capital letters, Space and simple letters using if condition
Finally Display the Text as original Text

42
4.9 Conclusion
In this portfolio it was observed about XBee communication setup and how to configure
hardware devices. It was used two interface XBee module with Arduino Uno board. The XBee
connected with Arduino board will act as a receiver and Transmitter. The configurations for
receiver and transmitter were configured using the XCTU.

In this communication plain text should not be transmitted, Chiper text only should be transmit.
Issue was occurred in serial communication which plain text also get transmitting. To avoid this
separate communication build as a solution (cipertx.begin(9600);).

At the receiving end problem were occurred because of LCD and Xbee module both required
Transmit (TX) and Receive (RX) port, to overcome the problem separately two ports configured
to communication in Arduino board.

In coding part issue occurred due to space, space also identified as a character by Arduino. If
condition was applied to avoid it.

43
4.10 Further Implementation

In the lab we used to XBee modules to transmit the encrypted text from one location and it
decrypted in other end. This can develop to use in Local Area Network to exchange confidential
data like Banks, Stock market or any other Security related companies.

Xbee module can develop in both industrial and home automation applications.

It can use in Automation, manufacturing and production industries. In those situation


communication link continually monitors various parameters and critical equipment
performance. It will cost using industrial wireless communication methods, Hence Zigbee
considerably reduce this communication cost as well as optimizes the control process reliability.

In Home Automation Zigbee is perfectly can use for controlling home appliances remotely as a


lighting system control, appliance control, heating and cooling system control, safety equipment
operations and control, surveillance.

44
5.Resources
 https://tutorial.cytron.io/2011/03/06/is-xbee-zigbee/
 http://shallowsky.com/arduino/class/buzzer.html
 https://diagrams.visual-paradigm.com/#
 https://prezi.com/k1lmgvmet0zh/the-industrial-revolution-morse-code/
 http://wikid.io.tudelft.nl/WikID/index.php/XBee
 https://www.geeksforgeeks.org/caesar-cipher/

45

You might also like