Skip to content

Instantly share code, notes, and snippets.

View CytronTH's full-sized avatar

Cytron Thailand CytronTH

  • Cytron Thailand
View GitHub Profile
@CytronTH
CytronTH / pico-traffic-light.py
Created October 6, 2021 03:12
Make your traffic light simulator from Raspberry Pi Pico with Micropython
import machine
import utime
led1_red = machine.Pin(2,machine.Pin.OUT)
led1_amber = machine.Pin(3,machine.Pin.OUT)
led1_green = machine.Pin(4,machine.Pin.OUT)
led2_red = machine.Pin(6,machine.Pin.OUT)
led2_amber = machine.Pin(7,machine.Pin.OUT)
led2_green = machine.Pin(8,machine.Pin.OUT)
@CytronTH
CytronTH / coin_th.ino
Created February 3, 2023 08:55
coin sorting machine sourcecode for thai currency
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // set the LCD address to 0x27 for a 16 chars and 2 line display
#define _1BATH 3
#define _2BATH 4
#define _5BATH 5
#define _10BATH 6
#define PIEZO 8
int count_1BATH = 0;
@CytronTH
CytronTH / grovewifi.ino
Last active April 11, 2023 15:11
Please install TridentTD_LineNotify arduino libraries before compiling this code
#include <TridentTD_LineNotify.h>
#define SSID "Your wifi SSID"
#define PASSWORD "Your wifi Password"
void setup() {
Serial.begin(115200);
Serial.println("WiFi connecting...");
WiFi.begin(SSID, PASSWORD);
while (!WiFi.isConnected()) delay(400);
@CytronTH
CytronTH / line_notify_grovewifi.ino
Created January 11, 2024 04:32
Line Notify for micro:bit using GroveWifi
#include <TridentTD_LineNotify.h>
#define SSID "Your WiFi SSID"  //ชื่อ WiFi ที่จะใช้
#define PASSWORD "You WiFi Password" //รหัสผ่านของ WiFi ที่จะใช้
void setup() {
  Serial.begin(115200, SERIAL_8N1);
  Serial.println("WiFi connecting...");
  WiFi.begin(SSID, PASSWORD);
  while (!WiFi.isConnected()) delay(400);
@CytronTH
CytronTH / docker-compose.yml
Created January 24, 2024 18:16
Data logger software deploy using docker-compose
version: "3"
services:
#Portainer - For manage container
portainer:
image: portainer/portainer-ce:latest
ports:
- "9443:9443"
volumes:
@CytronTH
CytronTH / robot_arm.ino
Created February 29, 2024 03:53
Robot arm using Maker Uno and servo motor
#include <Servo.h>
Servo Servo_X;
Servo Servo_Y;
Servo Servo_Grip;
#define Joy_X A0
#define Joy_Y A1
#define BUTTON 2
@CytronTH
CytronTH / control_relay_gpio17&27.py
Created July 2, 2024 15:37
Test how to control relay connect to Raspberry Pi 5 GPIO27 and GPIO17
import gpiod
import time
# Define GPIO chip and lines
chip = gpiod.Chip('gpiochip0')
relay1_line = chip.get_line(17)
relay2_line = chip.get_line(27)
# Configure GPIO lines as outputs
config = gpiod.line_request()
@CytronTH
CytronTH / crosshair.py
Created July 5, 2024 10:40
Raspberry Pi 5 access camera module 3 and draw crosshair in the middle
import cv2
from picamera2 import Picamera2
# Initialize the camera
picam2 = Picamera2()
picam2.configure(picam2.create_preview_configuration(main={"format": 'XRGB8888', "size": (640, 480)}))
picam2.start()
cv2.startWindowThread()
@CytronTH
CytronTH / pzemjetson.py
Created August 27, 2024 09:12
Read data from PZEM-004t via USB using Jetson Nano
import serial
import struct
import time
# Initialize the serial connection to the PZEM-004T
# Replace '/dev/ttyUSB0' with the appropriate port on your Jetson Nano
serial_port = '/dev/ttyUSB0'
baud_rate = 9600
def read_pzem(serial_connection):
@CytronTH
CytronTH / pwm_fan_config
Created September 8, 2024 14:31
Configuration for who want to make Raspberry Pi as cool as possible (Pi 5 only)
#PWM Fan control
#fan_tempX is temperature range in millicelcius
#fan_temp0_hyst is temperature range ensures that the fan doesn't turn on and off too frequently.
#fan_temp0_speed is speed of fan (min 0, max 255)
#Config below set PWM fan work:
# Fan speed 25% at 35 Celcius
# Fan speed 50% at 40 Celcius
# Fan speed 75% at 45 Celcius
# Fan speed 100% at 50 Celcius