Skip to content

Instantly share code, notes, and snippets.

View suadanwar's full-sized avatar

Suad Anwar suadanwar

View GitHub Profile
@suadanwar
suadanwar / UltrasonicPico.py
Created June 16, 2021 16:21
The sample code for ultrasonic sensor with Raspberry Pi Pico
from machine import Pin, PWM
import utime
Trig = Pin(27, Pin.OUT)
Echo = Pin(26, Pin.IN, Pin.PULL_DOWN)
Buzzer = PWM(Pin(18))
def CheckDistance():
SpeedOfSoundInCM = 0.034
@suadanwar
suadanwar / OttoMakerPiRP2040.ino
Created June 5, 2021 16:53
This sample code is for OTTO DIY Robot using Maker Pi RP2040.
/* 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 April 26, 2021 06:10
This sample code is for pelita 3d printing project using arduino.
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 April 9, 2021 03:43
This sample code is for Servo with Raspberry Pi Pico using CircuitPython
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 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 / 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 / DataLogger.py
Created February 26, 2021 10:51
This is sample code for Read and Log Internal Temperature Data in Raspberry Pi Pico to .txt file tutorial.
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 May 20, 2024 19:14
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 / simple_alarm.ino
Last active November 30, 2020 10:30
This is sample code for Simple Alarm System Using Maker Nano's tutorial.
#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 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