Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View suadanwar's full-sized avatar

Suad Anwar suadanwar

View GitHub Profile
@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 / Barometer_grove.ino
Created October 30, 2020 03:33
This sample code is for measuring surrounding air pressure's tutorial using Grove Air Pressure Sensor(BMP280)
#include "Seeed_BMP280.h"
#include <Wire.h>
#include <Arduino.h>
#include <U8x8lib.h>
U8X8_SSD1306_128X64_ALT0_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE);
BMP280 bmp280;
void setup() {
Serial.begin(9600);
@suadanwar
suadanwar / DHT_grove.ino
Last active October 22, 2020 17:08
This sample code is for Read Surrounding Temperature and Humidity using Grove All In One Beginner Kit for Arduino's tutorial.
#include "DHT.h"
#include <Arduino.h>
#include <U8x8lib.h>
#define DHTPIN 3
#define DHTTYPE DHT11 // DHT 11
DHT dht(DHTPIN, DHTTYPE);
U8X8_SSD1306_128X64_ALT0_HW_I2C u8x8(/* reset=*/ U8X8_PIN_NONE);
#define LED 4
#define PIEZO 5
@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 / security_image.py
Created October 6, 2020 16:08
This sample code is for Raspberry Pi Security Camera with Motion Detector tutorial(image).
from gpiozero import MotionSensor
from picamera import PiCamera
import time
from time import sleep
pir = MotionSensor(4)
camera = PiCamera()
camera.rotation = 180
while True:
@suadanwar
suadanwar / security_video.py
Last active October 6, 2020 16:08
This sample code is for Raspberry Pi Security Camera with Motion Detector tutorial.
from gpiozero import MotionSensor
from picamera import PiCamera
import time
from time import sleep
pir = MotionSensor(4)
camera = PiCamera()
camera.rotation = 180
while True:
@suadanwar
suadanwar / camera.py
Created October 2, 2020 02:42
This sample code is for Getting Started with Raspberry Pi Camera(Record A Video).
from picamera import PiCamera
from time import sleep
camera = PiCamera()
camera.rotation = 180
camera.start_preview(fullscreen = False, window = (1300,10,640,480))
camera.start_recording('/home/pi/Desktop/video.h264')
sleep(5)
camera.stop_recording()
@suadanwar
suadanwar / camera.py
Created October 2, 2020 02:38
This is a sample code for Getting Started with Raspberry Pi Camera Tutorial(Take A Picture).
from picamera import PiCamera
from time import sleep
camera = PiCamera()
camera.rotation = 180
camera.start_preview()
sleep(5)
camera.capture('/home/pi/Desktop/image.jpg')
camera.stop_preview()
@suadanwar
suadanwar / smoke_detector
Created September 17, 2020 13:39
This sample code is for smoke detector using MQ2 sensor on Maker NANO
#define MQ2 A0
#define GREEN_LED 4
#define YELLOW_LED 5
#define RED_LED 6
#define PIEZO 8
int sensorValue = 0;
void setup()
{
Serial.begin(9600); // Initialize serial communications with the PC
@suadanwar
suadanwar / audio_doorbell.ino
Created September 10, 2020 06:20
This sample code is for Audio Dorbell Tutorial.
#pragma mark - Depend ESP8266Audio and ESP8266_Spiram libraries
#include <M5Stack.h>
#include <WiFi.h>
#include "AudioFileSourceSD.h"
#include "AudioFileSourceID3.h"
#include "AudioGeneratorMP3.h"
#include "AudioOutputI2S.h"
AudioGeneratorMP3 *mp3;
AudioFileSourceSD *file;