Thursday, February 27, 2025

***Hand_gesture_control_LED_and_Prothetic_hand_code_Arduino+VS_code***

//VS OpenCv

// Hand_gesture_Prothectic_hand


import cv2

import mediapipe as mp

import serial

import time


# Initialize serial communication with Arduino

arduino = serial.Serial(port='COM4', baudrate=9600, timeout=1)

time.sleep(2)  # Wait for the serial connection to initialize


# Initialize Mediapipe

mp_hands = mp.solutions.hands

hands = mp_hands.Hands()

mp_drawing = mp.solutions.drawing_utils


# Function to detect individual fingers (1 for up, 0 for down)

def detect_fingers(image, hand_landmarks):

    finger_tips = [8, 12, 16, 20]  # Index, Middle, Ring, Pinky

    thumb_tip = 4

    finger_states = [0, 0, 0, 0, 0]  # Thumb, Index, Middle, Ring, Pinky


    # Check thumb

    if hand_landmarks.landmark[thumb_tip].x < hand_landmarks.landmark[thumb_tip - 1].x:

        finger_states[0] = 1  # Thumb is up


    # Check the other fingers

    for idx, tip in enumerate(finger_tips):

        if hand_landmarks.landmark[tip].y < hand_landmarks.landmark[tip - 2].y:

            finger_states[idx + 1] = 1  # Other fingers are up


    return finger_states


# Start capturing video

cap = cv2.VideoCapture(0)


while cap.isOpened():

    success, image = cap.read()

    if not success:

        break


    image = cv2.cvtColor(cv2.flip(image, 1), cv2.COLOR_BGR2RGB)

    results = hands.process(image)

    image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)


    if results.multi_hand_landmarks:

        for hand_landmarks in results.multi_hand_landmarks:

            mp_drawing.draw_landmarks(image, hand_landmarks, mp_hands.HAND_CONNECTIONS)

            fingers_state = detect_fingers(image, hand_landmarks)

            arduino.write(bytes(fingers_state))  # Send list of fingers as bytes

            print(f"Fingers State: {fingers_state}")


    cv2.imshow('Hand Tracking', image)

    if cv2.waitKey(5) & 0xFF == 27:

        break


cap.release()

cv2.destroyAllWindows()

arduino.close()




// Five LED control code, Here you can edit code for Servo hand gesture

//  https://youtu.be/DWg5l7zZXYU?si=7ze01J8l5ABSEhSA


int ledPins[] = {8, 9, 10, 11, 12};  // Thumb, Index, Middle, Ring, Pinky

void setup() {
  Serial.begin(9600);
  for (int i = 0; i < 5; i++) {
    pinMode(ledPins[i], OUTPUT);
  }
}

void loop() {
  if (Serial.available() >= 5) {  // Expect 5 bytes for 5 fingers
    for (int i = 0; i < 5; i++) {
      int fingerState = Serial.read();  // Read each finger state (0 or 1)
      digitalWrite(ledPins[i], fingerState == 1 ? HIGH : LOW);  // Turn LED on/off
    }
  }
}

Wednesday, February 26, 2025

Fire_sensor_sprinkler_water_pump

 #define SENSOR_PIN 2

#define BUZZER_PIN 3
#define RELAY_PIN 4
#define SPRINKLER_START_DELAY 1000  //5 seconds
#define SPRINKLER_ON_TIME 1000      //3 seconds Sprinkler on time

unsigned long previousTime = millis();

void setup()
{
  pinMode(RELAY_PIN, OUTPUT);
  pinMode(SENSOR_PIN, INPUT);  
}

void loop()
{
  //If there is fire then the sensor value will be LOW else the value will be HIGH
  int sensorValue = digitalRead(SENSOR_PIN);

  //There is fire
  if (sensorValue == LOW)
  {
    analogWrite(BUZZER_PIN, 50);                          //Turn on buzzer

    if (millis() - previousTime > SPRINKLER_START_DELAY)  //We will wait for few seconds before sprinkler can be started once fire is detected.
    {
      digitalWrite(RELAY_PIN, LOW);                       //Relay is low level triggered relay so we need to write LOW to switch on the light
      delay(SPRINKLER_ON_TIME);                           //Keep sprinkler on for sometime.
    }
  }
  else
  {
    analogWrite(BUZZER_PIN, 0);    
    digitalWrite(RELAY_PIN, HIGH);
    previousTime = millis();  
  }
}






Thursday, February 20, 2025

Soil moisture Irrigation

 // Circuit Pin Connection description:


// Soil Sensor connection:

// D0 -------------------->>>> Digital Pin - 6

// GND ------------------->>>> GND Arduino

// Vcc -------------------->>>> Vin Arduino

// Relay

// IN ------------------------>>>> Digital Pin - 3

// GND ---------------------->>>> GND Arduino

// Vcc ----------------------->>>> 3.3V

// Relay Screw-Driver

// 1 Pin ----------------------------->>>> Motor +ve

// 2 Pin(Middle) ------------------>>>> Battery +ve

// Motor -ve ---------------------->>>> Battery -ve

// Programming of given project:

int water; //random variable

void setup() {

pinMode(3,OUTPUT); //output pin for relay board, this will sent signal to the relay

pinMode(6,INPUT); //input pin coming from soil sensor

}

void loop() {

water = digitalRead(6); // reading the coming signal from the soil sensor

if(water == HIGH) // if water level is full then cut the relay

{

digitalWrite(3,LOW); // low is to cut the relay

}

else

{

digitalWrite(3,HIGH); //high to continue proving signal and water supply

}

delay(400);

}


// Project :- 2 : In the same project you can use Rain sensor module

// Problem/Troublesooting

// If relay’s green LED not glowing then change the Arduino.
// Change 1st wire on screw driver side.
// Servo door lock using Bluetooth : code

// void loop() {

//   if (Serial.available() > 0) {

//     char command = Serial.read();  // Read the incoming command from Bluetooth



//     // Adjust the positions of the servo motors based on the received command

//     if (command == 'L') {

//       pos1 = constrain(pos1 - 90, MIN_ANGLE, MAX_ANGLE);  // Move motor 1 left

//       pos2 = constrain(pos2 - 90, MIN_ANGLE, MAX_ANGLE);  // Move motor 2 left

//       pos3 = constrain(pos3 - 90, MIN_ANGLE, MAX_ANGLE);  // Move motor 3 left

//     } else if (command == 'R') {

//       pos1 = constrain(pos1 + 90, MIN_ANGLE, MAX_ANGLE);  // Move motor 1 right

//       pos2 = constrain(pos2 + 90, MIN_ANGLE, MAX_ANGLE);  // Move motor 2 right

//       pos3 = constrain(pos3 + 90, MIN_ANGLE, MAX_ANGLE);  // Move motor 3 right

//     }



//     // Set the new positions of the servo motors

//     servo1.write(pos1);

//     servo2.write(pos2);

//     servo3.write(pos3);
//     // Print the current positions to the Serial Monitor

//     Serial.print("Servo 1 Position: ");

//     Serial.println(pos1);

//     Serial.print("Servo 2 Position: ");

//     Serial.println(pos2);

//     Serial.print("Servo 3 Position: ");

//     Serial.println(pos3);

//   }

// }

Wednesday, February 19, 2025

Laser Home Security system Arduino

 




#include <SoftwareSerial.h>

int sensorPin = A0; // select the input pin for the LDR

int sensorValue = 0; // variable to store the value coming from the sensor

int led = 3;

void setup() { // declare the ledPin as an OUTPUT:

pinMode(led, OUTPUT);

Serial.begin(9600); }

void loop()

{

Serial.println("Sunil");

sensorValue = analogRead(sensorPin);

Serial.println(sensorValue);

if (sensorValue < 100)

{

Serial.println("LED light on");

digitalWrite(led,HIGH);

delay(1000);

}

digitalWrite(led,LOW);

delay(sensorValue);

}

Saturday, February 15, 2025

Python_RespberryPi_Project

1. While human detected light will ON https://youtu.be/X_gM6voXwSU?si=4VgMglK2elzYcYDa

2. AI Car:  https://youtu.be/8_c4KT0-n90?si=EA85mhIqk6tDG8qq

3.Leaf dead: https://youtu.be/9vOFApK-5kU?si=kHM2UFLOOnTcsyA7

4. Disease detection: https://youtu.be/OGT8hUggabg?si=d_7P2DVts-SQrBq3

5. Light detection dot matrix: https://youtube.com/shorts/T-j6sHIzUO0?si=-ZnfmTmclvVITDUE

6. Face detection who is that person      https://youtu.be/lH01BgsIPuE?si=HEtwGK2hKs8Y5RMJ

Thursday, February 13, 2025

Watch_RTC_based_idea

 

1️⃣ Smart Medicine Reminder Watch ⏰💊

  • Use Case: Helps elderly people take medicines on time.
  • Working: The RTC module checks the time and triggers a buzzer + LCD message to remind the user.

2️⃣ RFID-Based Employee Attendance System with Time Logging 🏢

  • Use Case: Tracks employee attendance along with login/logout times.
  • Working: The RFID card is scanned, and the system logs the exact time of entry/exit using the RTC module.

3️⃣ Automatic School Bell System 🔔🏫

  • Use Case: Automates the ringing of a school bell based on pre-set times.
  • Working: When the RTC time matches the predefined schedule, a relay activates the bell.

4️⃣ Digital Clock with Temperature Display ⏲🌡

  • Use Case: A simple real-time digital clock with date, time, and temperature display.
  • Working: The RTC provides the time, and a temperature sensor (like DS18B20) displays the temperature.

5️⃣ Smart Irrigation System with RTC Scheduling 🚜💧

  • Use Case: Automatically turns ON/OFF irrigation based on time.
  • Working: At specific times set in the RTC, a relay activates the water pump for irrigation.

6️⃣ Automated Street Light System 💡🌃

  • Use Case: Controls street lights based on time instead of light sensors.
  • Working: At a set time (e.g., 6:30 PM), lights turn ON. At 6:00 AM, lights turn OFF.

7️⃣ Real-Time Data Logger with SD Card 📊🖥

  • Use Case: Records sensor data (e.g., temperature, humidity) along with a timestamp.
  • Working: The RTC logs the exact date and time of sensor readings, storing them on an SD card.

8️⃣ Prayer Time Alert System 🕌🔔

  • Use Case: Helps in religious places to automatically announce prayer times.
  • Working: The RTC triggers an alarm or announcement at predefined prayer times.

9️⃣ Smart Home Automation Based on Time 🏠⚡

  • Use Case: Controls home appliances like fans, lights, and ACs based on schedule.
  • Working: The RTC triggers a relay at set times to turn ON/OFF appliances.

🔟 RTC-Based Countdown Timer for Exam or Quiz ⏳📖

  • Use Case: A countdown timer for students during exams.
  • Working: The RTC tracks the remaining time and displays it on an LCD screen.

RFID_Toll_tax_collection

  #include <SPI.h>

#include <MFRC522.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h>

#define SS_PIN 10
#define RST_PIN 9
MFRC522 rfid(SS_PIN, RST_PIN);

LiquidCrystal_I2C lcd(0x27, 16, 2);
Servo tollGate;

String card1 = "23222E28"; // Replace with actual UID
String card2 = "78E9F0G1H2"; // Replace with actual UID

int balance1 = 200;
int balance2 = 200;
int tollFee = 50;

void setup() {
    Serial.begin(9600);
    SPI.begin();
    rfid.PCD_Init();

    lcd.init();        // ✅ Fixed: Initialize LCD properly
    lcd.backlight();   // ✅ Fixed: Turn on LCD backlight
   
    lcd.setCursor(2, 0);
    lcd.print("RFID Toll Tax");
    delay(3000);
    lcd.clear();

    tollGate.attach(6);
    tollGate.write(0);
}

void loop() {
    if (!rfid.PICC_IsNewCardPresent() || !rfid.PICC_ReadCardSerial()) {
        return;
    }

    String readID = "";
    for (byte i = 0; i < rfid.uid.size; i++) {
        readID += String(rfid.uid.uidByte[i], HEX);
    }
    readID.toUpperCase();
    Serial.println("Card Detected: " + readID);

    lcd.clear();
    lcd.setCursor(0, 0);
   
    if (readID == card1) {
        processToll(balance1, "Card 1");
    } else if (readID == card2) {
        processToll(balance2, "Card 2");
    } else {
        lcd.print("Unauthorized Card");
        Serial.println("Unauthorized Card");
        delay(1500);
    }

    rfid.PICC_HaltA();
    rfid.PCD_StopCrypto1();
}

void processToll(int &balance, String cardName) {
    if (balance >= tollFee) {
        balance -= tollFee;
        lcd.print(cardName);
        lcd.setCursor(0, 1);
        lcd.print("Paid: Rs 50");
        Serial.println(cardName + " Paid Rs 50");
       
        tollGate.write(90);
        delay(2000);
        tollGate.write(0);

        lcd.clear();
        lcd.setCursor(0, 0);
        lcd.print("Bal: Rs " + String(balance));
        Serial.println("Remaining Bal: Rs " + String(balance));
    } else {
        lcd.print(cardName);
        lcd.setCursor(0, 1);
        lcd.print("Insufficient Bal");
        Serial.println(cardName + " Insufficient Balance");
    }
    delay(1500);
}

RFID_Project_Idea

 

1️⃣ RFID-Based Smart Parking System 🚗

  • Concept: Each car has an RFID card for parking access.
  • Working: When the RFID card is scanned, the parking gate opens, and a fee is deducted from the balance.

2️⃣ RFID Attendance System 🏫

  • Concept: Use RFID cards as ID cards for students/employees.
  • Working: When scanned, it marks attendance, displays the name on LCD, and records data in the system.

3️⃣ RFID Library Management System 📚

  • Concept: Books have RFID tags, and students have RFID ID cards.
  • Working: When a student scans their card and a book’s RFID tag, the book is issued or returned automatically.

4️⃣ RFID-Based Automatic Door Lock System 🚪

  • Concept: Only authorized people with RFID cards can enter a restricted area.
  • Working: When an authorized card is detected, the door unlocks (using a servo motor).

5️⃣ RFID-Based Canteen Payment System 🍽

  • Concept: RFID cards act as digital wallets for school/office canteens.
  • Working: When scanned, the meal cost is deducted from the balance, and the remaining balance is shown on the LCD.

6️⃣ RFID Fuel Station Payment System

  • Concept: Vehicles have RFID cards linked to their fuel accounts.
  • Working: The RFID card is scanned at a fuel station, payment is deducted, and the remaining balance is displayed.

7️⃣ RFID-Based Metro Train Ticketing System 🚆

  • Concept: Passengers use RFID cards as prepaid metro cards.
  • Working: When scanned at the entry gate, ₹50 is deducted, and the gate opens.

8️⃣ RFID-Based Hospital Patient Management 🏥

  • Concept: Patients have RFID cards that store their medical history.
  • Working: When scanned, patient details appear on the LCD, and access to medical records is granted.

9️⃣ RFID-Based Smart Locker System 🔒

  • Concept: A smart locker that opens only with authorized RFID cards.
  • Working: When the correct card is scanned, the locker opens via a servo motor.

🔟 RFID-Based E-Voting System 🗳

  • Concept: Citizens use RFID cards as voter IDs.
  • Working: When scanned, voter authentication is verified, and voting is allowed.

MUD Three Mode operation Manual Automatic GPS

 Code for three mode operation: /*   3-Mode Headlight Controller   - Manual mode (driver uses a toggle to pick high/low)   - Auto mode (LDR...