Skip to content

Instantly share code, notes, and snippets.

@ThaiEasyElec
ThaiEasyElec / 01_password.ino
Last active July 23, 2019 10:35
Home Alarm Systems
#include <Password.h>
#include <Keypad.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
Password password = Password( "1234" ); // Set the Password
// Set the LCD address to 0x27 for a 20 chars and 4 line display
LiquidCrystal_I2C lcd(0x27, 20, 4);
@ThaiEasyElec
ThaiEasyElec / 02_mapkey.ino
Last active July 23, 2019 10:36
Home Alarm System
void setup()
{
Serial.begin(9600); // Define Serial for Debug Sensor & Keyped
lcd.begin(); //Define LCD
lcd.backlight();
pinMode(status_lock, OUTPUT); // Sets the digital pin as output
pinMode(status_unlock, OUTPUT); // Sets the digital pin as output
pinMode(led_bed, OUTPUT); // Sets the digital pin as output
pinMode(led_bath, OUTPUT); // Sets the digital pin as output
pinMode(Buzzer, OUTPUT); // Sets the digital pin as output
@ThaiEasyElec
ThaiEasyElec / 03_checksensor.ino
Last active July 23, 2019 10:36
Home Alarm System
//take care of some special events
void keypadEvent(KeypadEvent eKey){
switch (keypad.getState()){
case PRESSED:
//Serial.print("Pressed: ");
//Serial.println(eKey);
lcd.setCursor(dir1, 3);
lcd.print(test);
test = "*";
lcd.setCursor(dir, 3);
@ThaiEasyElec
ThaiEasyElec / 04_checkPassword.ino
Created July 23, 2019 10:28
Home Alarm System
void checkPassword(){ // Function check the password
if (password.evaluate()){
//Add code to run if it works
while(1){
//Serial.println("Success");
fl = 1;
digitalWrite(status_lock, LOW);
digitalWrite(status_unlock, HIGH);
lcd.setCursor(0, 3);
lcd.print(" ** Home Unlock ** ");
void close_all_power(){ // Function close the light all.
digitalWrite(status_lock, HIGH);
digitalWrite(status_unlock, LOW);
digitalWrite(led_bed, LOW);
digitalWrite(led_bath, LOW);
}
void Alarm(){ // Function Alarm.
digitalWrite(Buzzer, HIGH); // Turn on Buzzer
delay(100); // delay 100 milliseconds
digitalWrite(Buzzer, LOW); // Turn off Buzzer
void motion_on() { // Function Open PIR Motion Sensor.
alarmValue = digitalRead(pir); // Read analog sensor 0 or 1.
//Serial.println (alarmValue); // Debug Sensor value.
if (alarmValue == 0) // Check the value
{
Alarm();
}
else
{
Alarm_off();
@ThaiEasyElec
ThaiEasyElec / smart_water_monitoring_1.ino
Last active September 11, 2019 03:44
smart water monitoring ch 1 read sensor and show on lcd
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
#define pHPin A0 //pH meter Analog output to Arduino Analog Input 0
#define turbidityPin A1 //Turbidity Analog output to Arduino Analog Input 1
#define tempPin A2 //Temperature sensor Analog output to Arduino Analog Input 2
#define Offset 0.00 //deviation compensate
#define ArrayLenth 40 //times of collection
@ThaiEasyElec
ThaiEasyElec / smart_water_monitoring_2.ino
Created September 19, 2019 10:01
smart_water_monitoring_2
#include <ArduinoMqttClient.h>
#include <SPI.h>
#include <WiFiNINA.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 4);
const char ssid[] = "YOUR_SSID";
const char pass[] = "YOUR_PASSWORD_SSID";
@ThaiEasyElec
ThaiEasyElec / car_pixy2.ino
Created December 18, 2019 09:14
car pixy2
#include <Pixy2.h>
#include <PIDLoop.h>
#include <ZumoMotors.h>
// กำหนดความเร็วสูงสุด (สูงสุด 400)
#define MAX_TRANSLATE_VELOCITY 200
Pixy2 pixy;
ZumoMotors motors;
@ThaiEasyElec
ThaiEasyElec / LED_Dot_Matrix_16x16.ino
Created January 28, 2020 08:41
LED_Dot_Matrix_16x16.ino
#include <Arduino.h>
#include <avr/pgmspace.h>
#include <SPI.h>
const byte STCP_PIN = 7; // Latch
const byte DS_PIN = 11; // Data In
const byte SHCP_PIN = 13; // CLK
#define LEDARRAY_D 2 // ขาที่ใช้ในการควบคุมแถวแนวนอน
#define LEDARRAY_C 3 // ขาที่ใช้ในการควบคุมแถวแนวนอน