Skip to content

Instantly share code, notes, and snippets.

View tieubinhco's full-sized avatar
🍉
Coding

Tieu Binh tieubinhco

🍉
Coding
  • A2Technology
  • HCMC
View GitHub Profile
@tieubinhco
tieubinhco / ENV.txt
Created April 25, 2021 16:32
Activate virtual environment python vs code bypass Window 10 restriction powershell
Set-ExecutionPolicy Unrestricted -Scope Process
@tieubinhco
tieubinhco / GetIP.py
Created April 7, 2021 02:34
Get IP address python
## importing socket module
import socket
## getting the hostname by socket.gethostname() method
hostname = socket.gethostname()
## getting the IP address using socket.gethostbyname() method
ip_address = socket.gethostbyname(hostname)
## printing the hostname and ip_address
print(f"Hostname: {hostname}")
print(f"IP Address: {ip_address}")
@tieubinhco
tieubinhco / DefinePinESP.cpp
Created April 1, 2021 04:27
Define pin esp32 for 2 motors
#define IN1_L 27 //motor Left Pin1
#define IN2_L 26 //motor Left Pin2
#define IN1_R 33 //motor Right Pin1
#define IN2_R 32 //motor Right Pin2
#define PWM_L 14 //PWM motor Left pin
#define PWM_R 14 //PWM motor Right pin
#define ENA_L 16 //Encoder A motor Left
#define ENB_L 17 //Encoder B motor Left
#define ENA_R 18 //Encoder A motor Right
#define ENB_R 19 //Encoder B motor Right
@tieubinhco
tieubinhco / WiFi_Arduino.ino
Created March 30, 2021 04:17
Wifi control Arduino
#include <SoftwareSerial.h>
/* Pins 8, 9, 10 and 11 of Arduino are connected to L298N Motor Driver Input pins i.e.
IN1, IN2, In3 and IN4 respectively*/
#define IN1 8
#define IN2 9
#define IN3 10
#define IN4 11
#define DEBUG true
@tieubinhco
tieubinhco / Speed.py
Last active April 28, 2021 05:01
Calculate speed using vision python
def estimateSpeed(location1, location2):
d_pixels = math.sqrt(math.pow(location2[0] - location1[0], 2) + math.pow(location2[1] - location1[1], 2))
# ppm = location2[2] / carWidht
ppm = 8.8
d_meters = d_pixels / ppm
#print("d_pixels=" + str(d_pixels), "d_meters=" + str(d_meters))
fps = 18
speed = d_meters * fps * 3.6
return speed
@tieubinhco
tieubinhco / ProjectilewithDrag.m
Created January 3, 2021 15:57
Projectile Motion of a particle with drag force
%Projectile motion
clear all
close all
clc
global g
global h
global m
g=9.81;
h=0.3;
@tieubinhco
tieubinhco / input.m
Last active December 8, 2020 07:00
Input values MATLAB
T5=[130 131 132 133 134];
X8=zeros(length(T5));
X5=zeros(length(T5));
for i=1:length(T5)
X8(i)=XsolCarrol(T2,T1);
X5(i)=XsolCarrol(T1,T5(i));
end
@tieubinhco
tieubinhco / EOQ_calculate.m
Last active December 25, 2020 03:41
MATLAB script to calculate Economic Order Quantity Model (EOQ)
clear
clc
%syms Q H S P D
D=40*10^6;
S=10000;
H=0.1;
P=5;
Working_days=250; %(days)
Lag_time=7; %(days)
%syms Q
@tieubinhco
tieubinhco / gauss.m
Created December 3, 2020 16:44
Gauss - Seidel MATLAB
function x=gauss(A,b)
%This function solves system of algebraic equations using Gaussian method
%Ax=b
%Input: matrix A, column vector b
%Output vector x
n=size(A,1);
b=b(:); %make sure b is a column vector.
nb=n+1;
Ab=[A b]; %extended matrix
@tieubinhco
tieubinhco / ReadSpeedEncoderMotor_Arduino.ino
Last active December 1, 2020 13:55
Code read speed of dc motor with encoder Arduino (quadrature) output RPM
#include <Encoder.h>
#define IN1 7
#define IN2 8
#define PWM 5
#define EN_A 2
#define EN_B 3
//Declare encoder function
Encoder Enc(EN_A, EN_B);