DENC2453 Microcontroller: Name Matrix Number
DENC2453 Microcontroller: Name Matrix Number
MICROCONTROLLER
NAME MATRIX NUMBER
SIRENJEEVI RAO A/L LOGANATHAN D021710304
NORAZRAI DANIEL AFIQ BIN RAZALI D021710230
AREVIND A/L SALVARAJU D021710138
DEVAKARAN A/L RAKU D021710300
LEE XIAO XUAN D021710196
PROJECT ASSIGNMENT
LECTURER NAME :-
Muhammad Raihaan Kamarudin
Overview
Nowadays the theft becomes widely in our nation especially robbing in house. So to prevent
this, we like to introduce a brand new housing alarm system. Our alarm system comprised of
Arduino UNO, servo motor and Bluetooth module. The working principle of this alarm is
when a person enters the house, the person needs to enter the password which can be set by
changing the default password in the codes. The user needed to enter the password to unlock
and lock the door. As the users enter the password using their smartphone and connect their
` No
Password ==
1234
\
Yes
No Door Open
Password ==
1234
Yes
Door Close
End
Discussion
#include <Servo.h>
void setup(){
//start serial connection
Serial.begin(9600); // baud rate is 9600 must match with bluetooth
//The String reserve() function allows you to allocate a buffer in memory for manipulating
strings.
inputString.reserve(50); // reserve 50 bytes in memory to save for string manipulation
command.reserve(50);
value.reserve(50);
void loop(){
// if arduino receive a string termination character like \n stringComplete will set to true
if (stringComplete) {
//Serial.println(inputString);
delay(100);
// identified the posiion of '=' in string and set its index to pos variable
int pos = inputString.indexOf('=');
// value of pos variable > or = 0 means '=' present in received string.
if (pos > -1) {
// substring(start, stop) function cut a specific portion of string from start to stop
// here command will be the portion of received string till '='
// let received string is open=test123
// then command is 'open'
command = inputString.substring(0, pos);
// value will be from after = to newline command
// for the above example value is test123
// we just ignoreing the '=' taking first parameter of substring as 'pos+1'
// we are using '=' as a separator between command and vale
// without '=' any other character can be used
// we are using = menas our command or password must not contains any '=', otherwise it
will cause error
value = inputString.substring(pos+1, inputString.length()-1); // extract command up
to \n exluded
//Serial.println(command);
//Serial.println(value);
void serialEvent() {
while (Serial.available()) {
// get the new byte:
char inChar = (char)Serial.read();
//Serial.write(inChar);
// add it to the inputString:
inputString += inChar;
// if the incoming character is a newline or a carriage return, set a flag
// so the main loop can do something about it:
if (inChar == '\n' || inChar == '\r') {
stringComplete = true;
}
}
}
void openDoor(){
myservo.write(0);
delay(0);
}
void closeDoor(){
myservo.write(65);
delay(0);
}