Final Report

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

6.

0 METHODOLOGY

This important chapter explains in detail the samples, instruments, materials,


procedures and data gathering methods used in the research.

6.1 Introduction

What is the methodology? A methodology is a plan-of-attack, especially when that


plan-of-attack is used repeatedly. This might be obvious, but the word methodology is
related to the word method. A methodology is a system of methods followed
consistently. Scientists, for example, use various methodologies as they perform
experiments. It might seem like the world is nothing but chaos and disorder. But
actually, sometimes there is a method to this madness. And sometimes there’s a
methodology.

In this chapter, we describe about the steps and process to implement the project
activities which is from the beginning of the step until the end of the step. Other than
that, we also include the schematic diagram, block diagram and so on to make this
project more detail and clearly
6.2 Project Design and Overview

Project Design is the project details how the project will be managed. The explanation
of the writer's project design by using a suitable diagram should be placed here. This
explanation should include;
6.2.1 Plans and the procedures for research that span the decisions from
broad assumption to detailed methods of data collection and analysis.
6.2.2 The plan involves several decisions.
6.2.3 The overall decision involves which design should be used to study a
topic.

6.2.1 Block Diagram of the Project

Figure 6. 1 Example of Block diagram for Automatic Lighting Control


System
6.2.2 Flow Chart of the Project

f
Figure 6. 2 Example of flow chart for the overall project
6.2.3 Project Description

In this subtopic, the project we created Smart Awareness Watch is using an Arduino
UNO where the function of this Arduino is to perform analog ang digital on this
machine. When using an Arduino, the coding needs to be filled in before we can make
the machine turn on and of the light automatically. We also created this project using
apps Proteus Professional 8 which can make it easier for users when operating it.

6.3 Project Hardware and Description

I. Arduino UNO

Arduino UNO is a microcontroller board based on the ATmega328P. It has 14 digital


input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz
ceramic resonator, a USB connection, a power jack, an ICSP header and a reset button. It
contains everything needed to support the microcontroller; simply connect it to a computer
with a USB cable or power it with an AC-to-DC adapter or battery to get started. You can
tinker with your UNO without worrying too much about doing something wrong, worst-
case scenario you can replace the chip for a few dollars and start over again.

Figure 1. Arduino UNO


II. HC05 Bluetooth module

HC-05 is a Bluetooth module which can communicate in two ways. Which means, it is
full-duplex. We can use it with most micro controllers. Because it operates Serial Port
Protocol (SSP). The module communicates with the help of USART (Universal
Synchronous/Asynchronous Receiver/Transmitter) at the baud rate of 9600. and it also
support other baud rate. So, we can interface this module with any microcontroller which
supports USART. The HC-05 can operate in two modes. One is Data mode and other is
AT command mode. When the enable pin is "LOW" the HC-05 is in Data Mode. If that
pin set as "HIGH" the module is in AT command mode. Here we operate this module in
Data Mode.

Figure 2. HC05 Bluetooth Module


III. Motion Sensor

A motion sensor, or motion detector, is an electronic device that uses a sensor to detect
nearby people or objects. Motion sensors are an important component of any security
system. When a sensor detects motion, it will send an alert to your security system, and
with newer systems, right to your mobile phone.

Figure 3. Motion Sensor

IV. Relay

A relay is an electrically operated switch. It consists of a set of input terminals for a


single or multiple control signals, and a set of operating contact terminals. The switch
may have any number of contacts in multiple contact forms, such as make contacts,
break contacts, or combinations thereof. Relays are used where it is necessary to control
a circuit by an independent low-power signal, or where several circuits must be
controlled by one signal. Relays were first used in long-distance telegraph circuits as
signal repeaters: they refresh the signal coming in from one circuit by transmitting it on
another circuit. Relays were used extensively in telephone exchanges and early
computers to perform logical operations.

Figure 4. Relay
6.3.1 Circuit Operation

The operating circuit for this project is that we create a model of a machine that can
be used to automatically turn off and on the lighting system. We use the Arduino
UNO which will be connected to switch, Bluetooth module apps, and motion sensor
that is how we turn it on, this machine model will do their job by itself without
controlling it much.

6.4 Project Software and Coding that were used in this project.

For this project, we used an ATmega328P to run the machine model we created as an
example. This ATmega328P, we need to enter the coding before we are on the model
robot. This coding we can insert into Arduino software and Proteus software which
we can also insert into circuits.
Figure 3.4 Example of coding that insert into Arduino software
Coding for Second Arduino UNO

#include <SoftwareSerial.h>
#include <Servo.h>

#define arduino_rx_pin 10 //must be inturrpt pin


#define arduino_tx_pin 11 //
#define lcdSize 3 //this will define number of LCD on the phone app
int refreshTime = 3; //the app data will be updated every 3 seconds.

SoftwareSerial mySerial(arduino_rx_pin, arduino_tx_pin); // RX, TX

char pinsMode[54];
int pinsValue[54];
String feedBack;
String lcd[lcdSize];
unsigned long last = millis();
Servo servoArray[54];
String boardType;
String protectionPassword = "";
String appBuildVersion = "4.1";

void setup(void)
{
Serial.begin(9600);// set the data rate for the Hardware Serial port
mySerial.begin(9600);//you have to change this if you change bluetooth baudrate.
boardInit();
}

void loop(void)
{
lcd[0] = "Test 1 LCD";// you can send any data to your mobile phone.
lcd[1] = String(analogRead(1));// you can send any data to your mobile phone.
lcd[2] = String(random(1, 100)); // you can send any data to your mobile phone.
if ( mySerial.available() )
{
process();
}
update_input();
update_app();//will update all values in the mobile app.
}

void process() {

String command = mySerial.readStringUntil('/');

if (command == "digital") {
digitalCommand();
}

if (command == "pwm") {
pwmCommand();
}

if (command == "servo") {
servoCommand();
}

if (command == "terminal") {
terminalCommand();
}

if (command == "mode") {
modeCommand();
}

if (command == "allonoff") {
allonoff();
}

if (command == "refresh") {
refresh();
}

if (command == "password") {
changePassword();
}

if (command == "allstatus") {
feedBack = "refresh/";
allstatus();
}
}

void changePassword() {
String data = mySerial.readStringUntil('/');
protectionPassword = data;
}

void terminalCommand() {//Here you recieve data form app terminal

String data = mySerial.readStringUntil('/');


Serial.println(data);

String replyToApp = "Ok from Arduino"; //It can be change to any thing

feedBack = "terminal/" + replyToApp; //dont change this line.


allstatus();
}

void digitalCommand() {
int pin, value;
pin = mySerial.parseInt();
if (mySerial.read() == '/') {
value = mySerial.parseInt();
digitalWrite(pin, value);
pinsValue[pin] = value;
}
}
void pwmCommand() {
int pin, value;
pin = mySerial.parseInt();
if (mySerial.read() == '/') {
value = mySerial.parseInt();
analogWrite(pin, value);
pinsValue[pin] = value;
}

void servoCommand() {
int pin, value;
pin = mySerial.parseInt();
if (mySerial.read() == '/') {
value = mySerial.parseInt();
servoArray[pin].write(value);
pinsValue[pin] = value;
}
}

void modeCommand() {
int pin;
pin = mySerial.parseInt();
// mode_feedback = "";
if (mySerial.read() == '/') {
String mode = mySerial.readStringUntil('/');
if (mode == "output") {
pinMode(pin, OUTPUT);
digitalWrite(pin, 0);
pinsMode[pin] = 'o';
pinsValue[pin] = 0;
}
if (mode == "push") {
pinsMode[pin] = 'm';
pinsValue[pin] = 0;
pinMode(pin, OUTPUT);
digitalWrite(pin, 0);
}
if (mode == "schedule") {
pinsMode[pin] = 'c';
pinsValue[pin] = 0;
pinMode(pin, OUTPUT);
digitalWrite(pin, 0);
}

if (mode == "input") {
pinsMode[pin] = 'i';
pinsValue[pin] = 0;
pinMode(pin, INPUT);
}

if (mode == "pwm") {
pinsMode[pin] = 'p';
pinsValue[pin] = 0;
pinMode(pin, OUTPUT);
analogWrite(pin, 0);
}

if (mode == "servo") {
pinsMode[pin] = 's';
pinsValue[pin] = 0;
servoArray[pin].attach(pin);
servoArray[pin].write(0);
}
feedBack = "mode/" + mode + "/" + pin + "/" + pinsValue[pin];
allstatus();
}
}

void allonoff() {
int pin, value;
value = mySerial.parseInt();
for (byte i = 0; i < sizeof(pinsMode); i++) {
if (pinsMode[i] == 'o') {
digitalWrite(i, value);
pinsValue[i] = value;
}
}
}

void refresh() {
int value;
value = mySerial.parseInt();
refreshTime = value;
allstatus();
}

void update_input() {
for (int i = 0; i < sizeof(pinsMode); i++) {
if (pinsMode[i] == 'i') {
pinsValue[i] = digitalRead(i);
}
}
}

void update_app() {

if (refreshTime != 0) {
int refreshVal = refreshTime * 1000;
if (millis() - last > refreshVal) {
allstatus();
last = millis();
}
}
}

void allstatus() {
int digitalArraySize, analogArraySize;
if (boardType == "mega") {
digitalArraySize = 53;
analogArraySize = 15;
} else {
digitalArraySize = 13;
analogArraySize = 5;
}
String dataResponse;
dataResponse += "{";

dataResponse += "\"m\":[";//m for mode


for (byte i = 0; i <= digitalArraySize; i++) {
dataResponse += "\"";
dataResponse += pinsMode[i];
dataResponse += "\"";
if (i != digitalArraySize)dataResponse += ",";
}
dataResponse += "],";

dataResponse += "\"v\":[";//v for value


for (byte i = 0; i <= digitalArraySize; i++) {
dataResponse += pinsValue[i];
if (i != digitalArraySize)dataResponse += ",";
}
dataResponse += "],";

dataResponse += "\"a\":[";//a for analog value


for (byte i = 0; i <= analogArraySize; i++) {
dataResponse += analogRead(i);
if (i != analogArraySize)dataResponse += ",";
}
dataResponse += "],";

dataResponse += "\"l\":[";// for lcd


for (byte i = 0; i <= lcdSize - 1; i++) {
dataResponse += "\"";
dataResponse += lcd[i];
dataResponse += "\"";
if (i != lcdSize - 1)dataResponse += ",";
}
dataResponse += "],";

dataResponse += "\"t\":\""; //t for Board Type .


dataResponse += boardType;
dataResponse += "\",";
dataResponse += "\"f\":\""; //t for Board Type .
dataResponse += feedBack;
dataResponse += "\",";
dataResponse += "\"r\":\""; //t for Board Type .
dataResponse += refreshTime;
dataResponse += "\",";
dataResponse += "\"b\":\""; //b for app build version .
dataResponse += appBuildVersion;
dataResponse += "\",";
dataResponse += "\"p\":\""; // p for Password.
dataResponse += protectionPassword;
dataResponse += "\"";
dataResponse += "}";
mySerial.println(dataResponse);
feedBack = "";
}

void boardInit() {
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
for (byte i = 0; i <= 53; i++) {
if (i == 0 || i == 1 || i == arduino_rx_pin || i == arduino_tx_pin ) {
pinsMode[i] = 'x';
pinsValue[i] = 'x';
}
else {
pinsMode[i] = 'o';
pinsValue[i] = 0;
pinMode(i, OUTPUT);
}
}

#endif

#if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__) ||


defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega16U4__)
for (byte i = 0; i <= 13; i++) {
if (i == 0 || i == 1 || i == arduino_rx_pin || i == arduino_tx_pin ) {
pinsMode[i] = 'x';
pinsValue[i] = 'x';
}
else {
pinsMode[i] = 'o';
pinsValue[i] = 0;
pinMode(i, OUTPUT);
}
}
#endif

#if defined(__AVR_ATmega168__) || defined(__AVR_ATmega328P__)


boardType = "uno";
#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__) || defined(__SAM3X8E__)
boardType = "mega";
#elif defined(__AVR_ATmega32U4__)
boardType = "leo";
#else
boardType = "uno";
#endif
feedBack = "refresh/";
allstatus();

}
7.0 Result

7.1 Introduction

This subtopic will go through the projected outcomes of this project. Before
beginning this project, whether software or hardware work, a proposal work had to
be created. It had to investigate some information about this project so that we could
picture the expected results and determine whether or not the effort was effective.
To finish this project, we followed all of the processes to ensure that it did not fail
after it was finished.
7.2 Expected Result

Figure 7. Schematic Diagram of our project.

You might also like