Skip to content

Instantly share code, notes, and snippets.

View suadanwar's full-sized avatar

Suad Anwar suadanwar

View GitHub Profile
@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 / 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 / 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 / face_recognition.py
Last active April 5, 2021 01:04
This sample code is for Face Recognition Tutorial using Raspberry Pi OS, Pi Camera, Python 3, and OpenCV
import io
import picamera
import cv2
import numpy
#Create a memory stream so photos doesn't need to be saved in a file
stream = io.BytesIO()
#Get the picture (low resolution, so it should be quite fast)
#Here you can also specify other parameters (e.g.:rotate the image)
@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 / 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 / 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 / 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: