Skip to content

Instantly share code, notes, and snippets.

Avatar

Suad Anwar suadanwar

View GitHub Profile
@suadanwar
suadanwar / OttoMakerPiRP2040.ino
Created Jun 5, 2021
This sample code is for OTTO DIY Robot using Maker Pi RP2040.
View OttoMakerPiRP2040.ino
/* Otto DIY Robot
by Suad Anwar
This sample code is for Otto DIY Robot using Maker Pi RP2040 board.
https://my.cytron.io/p-maker-pi-rp2040-simplifying-robotics-with-raspberry-pi-rp2040
*/
#include <Servo.h>
#define PIN_YL 12 //servo[0] left leg
@suadanwar
suadanwar / Pelita.ino
Created Apr 26, 2021
This sample code is for pelita 3d printing project using arduino.
View Pelita.ino
const int LED = 10;
long random_led;
long random_time;
int difer_time();
void setup() {
pinMode(LED, OUTPUT);
}
int min_led = 200;
@suadanwar
suadanwar / servoPico.py
Created Apr 9, 2021
This sample code is for Servo with Raspberry Pi Pico using CircuitPython
View servoPico.py
import time
import board
import pwmio
from adafruit_motor import servo
# create a PWMOut object on Pin GP27.
pwm = pwmio.PWMOut(board.GP27, duty_cycle=2 ** 15, frequency=50)
# Create a servo object, my_servo.
my_servo = servo.Servo(pwm)
@suadanwar
suadanwar / keypad_solenoid.ino
Created Mar 24, 2021
This sample code is Solenoid Door Lock Using Keypad Tutorial.
View keypad_solenoid.ino
/*
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 / LED_Pico.py
Created Mar 12, 2021
This sample code is to Control WS2812B NeoPixel LED Stick Using Raspberry Pi Pico.
View LED_Pico.py
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 / DataLogger.py
Created Feb 26, 2021
This is sample code for Read and Log Internal Temperature Data in Raspberry Pi Pico to .txt file tutorial.
View DataLogger.py
import machine
import utime
sensor_temp = machine.ADC(machine.ADC.CORE_TEMP)
conversion_factor = 3.3 / (65535)
file = open("temps.txt", "w")
while True:
reading = sensor_temp.read_u16() * conversion_factor
temperature = 27 - (reading - 0.706)/0.001721
@suadanwar
suadanwar / face_lock.py
Last active Apr 17, 2021
This sample code is for Unlock A Door with Face Recognition Using OpenCV on Raspberry Pi.
View face_lock.py
#! /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 / simple_alarm.ino
Last active Nov 30, 2020
This is sample code for Simple Alarm System Using Maker Nano's tutorial.
View simple_alarm.ino
#define SENSOR 3
#define PIEZO 8
#define NOTE_G5 784
#define NOTE_C6 1047
int Sound[] = {NOTE_G5, NOTE_C6};
int SoundNoteDurations[] = {12, 8};
#define playSound() playMelody(Sound, SoundNoteDurations, 2)
@suadanwar
suadanwar / face_rec.py
Created Nov 12, 2020
This is sample code for Face Recognition using OpenCV on Raspberry Pi 400.
View face_rec.py
#! /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 / template_matching.py
Last active Nov 5, 2020
This is sample code for template matching tutorial using OpenCV on Raspberry Pi
View template_matching.py
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']