Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

Arduino codes

Aldrean

Novice
Advanced Member
Messages
43
Reaction score
3
Points
28
sino po magaling sa arduino dito baka pwede patulong po.. di ko po kasi napg cocombine tong dalawang codes na to yung sa lcd ayus naman po yun lang sa keypad parang nag lalag...


#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11);

// addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address

String cellnumber="09217323964";

const int PIRSensorPin1=5;
const int PIRSensorPin2=6;
boolean SMS_Sent=false;
int prevPIRvalue1=0;
int PIRvalue1=0;
int prevPIRvalue2=0;
int PIRvalue2=0;

void setup()
{
lcd.begin(20,4);
lcd.setCursor(0,0);
lcd.print("Initializing GSM...");
GSM_power_ON();
lcd.setCursor(0,0);
lcd.print("GSM Based Home Alarm");

pinMode(PIRSensorPin1,INPUT);
pinMode(PIRSensorPin2,INPUT);
Serial.begin(9600);

mySerial.begin(19200); //Default serial port setting for the GPRS modem is 19200bps 8-N-1
mySerial.print("\r");
delay(1000); //Wait for a second while the modem sends an "OK"


// mySerial.print("AT+CMGF=1\r"); //Because we want to send the SMS in text mode
// delay(1000);
/*
mySerial.print("AT+CMGS=\"+639228592146\"\r"); //Start accepting the text for the message
//to be sent to the number specified.
//Replace this number with the target mobile number.
delay(1000);
mySerial.print("Testing xxx!\r"); //The text for the message
delay(1000);
mySerial.write(0x1A); //Equivalent to sending Ctrl+Z
*/
}


void loop()
{
PIRvalue1 = digitalRead(PIRSensorPin1);
PIRvalue2 = digitalRead(PIRSensorPin2);
Serial.print("PIRvalue1: ");
Serial.println(PIRvalue1);
Serial.print("prevPIRvalue1: ");
Serial.println(prevPIRvalue1);
Serial.print("PIRvalue2: ");
Serial.println(PIRvalue2);
Serial.print("prevPIRvalue2: ");
Serial.println(prevPIRvalue2);
delay(1000);
if (PIRvalue1 == HIGH || PIRvalue2 == HIGH )
{
if (PIRvalue1!=prevPIRvalue1 || PIRvalue2!=prevPIRvalue2)
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Motion Detected!");
delay(1000);
lcd.clear();
Serial.println("Motion Detected");
Serial.println("Sending SMS");
sendSMS();
Serial.println("SMS Sent");
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Motion Detected!");
delay(1000);
lcd.clear();


}
//prevPIRvalue=PIRvalue;
}
else
{

}
prevPIRvalue1=PIRvalue1;
prevPIRvalue2=PIRvalue2;
}



void sendSMS()
{
mySerial.print("AT+CMGF=1\r"); //Because we want to send the SMS in text mode
delay(1000);

mySerial.print("AT+CMGS=\"+639175378262\"\r"); //Start accepting the text for the message
//to be sent to the number specified.
//Replace this number with the target mobile number.
// mySerial.print("AT+CMGS=\"*cellnumber"\r");
delay(1000);
mySerial.print("Motion Detected!\r"); //The text for the message
delay(1000);
mySerial.write(0x1A); //Equivalent to sending Ctrl+Z
}


void GSM_power_ON()
{
digitalWrite(9,HIGH);
delay(26000);

}




tyaka eto pa po...


#include<Keypad.h> //libraries
#include <LiquidCrystal_I2C.h>
#include<Servo.h>
Servo servo;
#define yled 5 //green led
#define kled 6 // red led
#define buzzer 4

LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

const byte row = 4; //rows
const byte column = 4; //columbs
char password[4] = {'1', '2', '3', '4'}; //default password we can change it from here and also change it int he void loop!
char encryption[4]; //password that we will click on the keypad
char key; //char key
int i = 0;
char key_pad[4][4] = { //key_pad 2 dimensional array name of the kayped
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};

byte row_pins[4] = {A0, A1, A2, A3}; //rows_pins connected which pins
byte column_pins[4] = {A4, A5, 3, 2}; //columb_pins connecting which pins

Keypad keys_pad = Keypad(makeKeymap(key_pad), row_pins, column_pins, 4, 4); // special code from Keypad library. basically create map usin name of keypad and row_pins,columb_pins


byte customChar9[8] = { //in order to create animation(LOADING EFFECT ) and custom character.

0b11111,
0b11111,
0b11111, // It has been taught in my other video how to create these custom characters: thermometer with animation effect.
0b11111,
0b11111,
0b11111,
0b11111,
0b11111
};
byte customChar8[8] = {
0b11110,
0b11110,
0b11110,
0b11110,
0b11110,
0b11110,
0b11110,
0b11110
};
byte customChar7[8] = {
0b11100,
0b11100,
0b11100,
0b11100,
0b11100,
0b11100,
0b11100,
0b11100
};
byte customChar6[8] = {
0b11000,
0b11000,
0b11000,
0b11000,
0b11000,
0b11000,
0b11000,
0b11000
};
byte customChar5[8] = {
0b10000,
0b10000,
0b10000,
0b10000,
0b10000,
0b10000,
0b10000,
0b10000
};
byte customChar4[8] = {
0b00001,
0b00011,
0b00011,
0b00111,
0b00111,
0b01111,
0b01111,
0b11111
};
byte customChar3[8] = {
0b00000,
0b00010,
0b00010,
0b00110,
0b00110,
0b01110,
0b01110,
0b11110
};
byte customChar2[8] = {
0b00000,
0b00000,
0b00000,
0b00100,
0b00100,
0b01100,
0b01100,
0b11100
};
byte customChar1[8] = {
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b01000,
0b01000,
0b11000
};

byte customChar0[8] = {
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b00000,
0b10000
};

void setup() {

servo.attach(13);
pinMode(yled, OUTPUT); //designating leds and buzzer as OUTPUT
pinMode(buzzer, OUTPUT);
pinMode(kled, OUTPUT);
lcd.createChar(0, customChar0);
lcd.createChar(1, customChar1);
lcd.createChar(2, customChar2);
lcd.createChar(3, customChar3);
lcd.createChar(4, customChar4);
lcd.createChar(5, customChar5);//other custom char starts from here
lcd.createChar(6, customChar6);
lcd.createChar(7, customChar7);
lcd.createChar(8, customChar8);
lcd.createChar(9, customChar9);
lcd.begin(16, 2); // LCD BEGAN
lcd.clear(); //Clear screen
lcd.clear();
lcd.setCursor(1, 0);
lcd.print("Hello");//Clear screen

for (int i = 1; i <= 13; i++) // used 2 for loop in order to create LOADING EFFECT
{


for (int k = 6; k <= 9; k++)
{
lcd.setCursor(i, 1); lcd.write((uint8_t)k);
delay(100);

}

}

lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Hello");//ARDUINO HOCAM
lcd.setCursor(0, 1);
lcd.print("Lock Door System"); // LOCK DOOR SYSTEM
delay(2000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Password:"); //YOU CAN PRINT HERE WHAT EVER YOU WANT ,THIS MEAN PASSWORD:
Serial.begin(9600);
Serial.println("Welcome"); //WELCOME
Serial.println("Encryption Priority");
}

void loop() {
servo.write(0);

digitalWrite(kled,LOW);
digitalWrite(yled,LOW);
key = keys_pad.getKey(); //getKey gets key when we click on the keypad

if (key) //if key (tus then it will process as follow
{
encryption[i++] = key; //everytime we click keypad ,sifre1=password1 will be [0] to [1] to[2].... till 4. element of array

lcd.setCursor(i, 1);
lcd.print("*"); // i have used * this charecter so that passwords that we print on the screen can not be seen from anyone else
digitalWrite(buzzer,HIGH);
delay(100);
digitalWrite(buzzer,LOW);// also when we clicked keypad ,buzzer will ring which make you feel like real system :)
}

if (i == 4)
{ delay(200);
char password[4] = {'*', '0', '9', '8'}; //default password u should write here like that

if ((strncmp(encryption, password, 4) == 0)) //comparing these passwords if first 4 element correct then process will be as follows
{
lcd.clear();
lcd.setCursor(0, 0);
servo.write(90);
lcd.print("PASSWORD ACCEPTED!"); //password correct
digitalWrite(yled, HIGH);
digitalWrite(kled, LOW);
digitalWrite(buzzer, HIGH);
delay(1000);
digitalWrite(buzzer, LOW);
delay(2000);
digitalWrite(buzzer, HIGH);
delay(2000);
digitalWrite(buzzer, LOW);
delay(1000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("ENCRYPTION PRIORITY"); //password :
i = 0;
}

else
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("INVALID PASSWORD!"); //wrong password
digitalWrite(yled, LOW);
digitalWrite(kled, HIGH);
digitalWrite(buzzer, HIGH);
delay(1000);
digitalWrite(buzzer, LOW);
delay(1000);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("ENCRYPTION PRIORITY"); //password :
i = 0;
}
}
}

patulong po salamat.. po ng marami
 
gamit ka ng library ng keypad na may animation daming unnecessary lines
 
Back
Top Bottom