Skip to content

Instantly share code, notes, and snippets.

View suadanwar's full-sized avatar

Suad Anwar suadanwar

View GitHub Profile
@suadanwar
suadanwar / video_telegram.py
Created October 16, 2020 04:27
This sample code is for Send video to telegram bot using Raspberry Pi tutorial.
import telepot
from picamera import PiCamera
import RPi.GPIO as GPIO
import time
from time import sleep
import datetime
from telepot.loop import MessageLoop
from subprocess import call
@suadanwar
suadanwar / face_lock.py
Last active November 20, 2023 01:24
This sample code is for Unlock A Door with Face Recognition Using OpenCV on Raspberry Pi.
#! /usr/bin/python
# import the necessary packages
from imutils.video import VideoStream
from imutils.video import FPS
import face_recognition
import imutils
import pickle
import time
import cv2
@suadanwar
suadanwar / face_rec.py
Created November 12, 2020 04:09
This is sample code for Face Recognition using OpenCV on Raspberry Pi 400.
#! /usr/bin/python
# import the necessary packages
from imutils.video import VideoStream
from imutils.video import FPS
import face_recognition
import imutils
import pickle
import time
import cv2
@suadanwar
suadanwar / calculator.ino
Created September 19, 2019 09:20
This sample code is for Calculator Using 4x4 Keypad and I2C LCD on Arduino.
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 20, 2); // set the LCD address to 0x27 for a 16 chars and 2 line display
#include <Keypad.h>
const byte ROWS = 4;
const byte COLS = 4;
char keys [ROWS] [COLS] = {
{'1', '2', '3', '+'},
@suadanwar
suadanwar / LED_Pico.py
Created March 12, 2021 05:03
This sample code is to Control WS2812B NeoPixel LED Stick Using Raspberry Pi Pico.
import array, time
from machine import Pin
import rp2
from rp2 import PIO, StateMachine, asm_pio
# Configure the number of WS2812 LEDs.
NUM_LEDS = 8
@asm_pio(sideset_init=PIO.OUT_LOW, out_shiftdir=PIO.SHIFT_LEFT,
autopull=True, pull_thresh=24)
@suadanwar
suadanwar / template_matching.py
Last active September 22, 2022 02:23
This is sample code for template matching tutorial using OpenCV on Raspberry Pi
import cv2
import numpy as np
img = cv2.imread("Cover.jpg")
gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
template = cv2.imread("Raspberry Pi.jpg", 0)
w, h = template.shape[::-1]
count = 0
res = cv2.matchTemplate(gray_img, template, cv2.TM_CCORR_NORMED )
#methods = ['cv.TM_CCOEFF', 'cv.TM_CCOEFF_NORMED', 'cv.TM_CCORR','cv.TM_CCORR_NORMED', 'cv.TM_SQDIFF', 'cv.TM_SQDIFF_NORMED']
@suadanwar
suadanwar / smart_blind_stick.ino
Created January 23, 2020 06:18
This sample code is for Smart Blind Stick Tutorial.
#define TRIGPIN1 2
#define ECHOPIN1 3
#define TRIGPIN2 5
#define ECHOPIN2 6
#define PIEZO 8
// defines variables
long Duration1;
int Distance1;
long Duration2;
@suadanwar
suadanwar / homenotification.py
Last active November 30, 2021 10:47
This sample code is for home notification using Telegram bot and Raspberry Pi.
import telepot
import RPi.GPIO as GPIO
import time
import datetime
from telepot.loop import MessageLoop
PIR = 17
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
@suadanwar
suadanwar / keypad_solenoid.ino
Created March 24, 2021 05:04
This sample code is Solenoid Door Lock Using Keypad Tutorial.
/*
Project: CUnlock the Soenoid Door Lock Using A Keypad and Maker Nano #ArduinoNano
Board: Arduino Nano (Maker Nano)
Connections:
Nano | Relay
GND – GND
5V – VCC
A0 – SIG
Nano | Keypad
@suadanwar
suadanwar / Solenoid_Relay.ino
Created January 30, 2020 08:57
This sample code is for Solenoid Door Lock with Relay on Arduino.
#define BUTTON 2 // the number of the pushbutton pin
#define RELAY 3 // the number of the relay pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
// initialize the LED pin as an output:
pinMode(RELAY, OUTPUT);
// initialize the pushbutton pin as an input: