Autonomous, contactless and hygienic IoT project designed with System Development Life Cycle (SDLC).

You can watch the hardware setup, solutions to technical challenges (servo jitter, insufficient current) and system working demo in the video below:
Increasing hygiene standards in public and private work spaces is critical to prevent diseases transmitted through contact. The main goal of this project is to design an autonomous 'Smart Trash Can' that completely eliminates physical contact.
The system is powered by the Raspberry Pi Pico 2 W board, featuring the new-generation dual-core RP2350 microcontroller. An ultrasonic sensor is used to detect approaching hands, and a high-torque servo motor moves the lid.

| Component | Pin / Lead | Pico 2 W Connection |
|---|---|---|
| HC-SR04 Sensor | VCC | External 5V Power Supply |
| GND | Common Ground (Pico Pin 3 - GND) | |
| Trig | GP15 (Pin 20) | |
| Echo | GP14 (Pin 19) | |
| MG995 Servo Motor | VCC (Red) | External 5V Power Supply |
| GND (Brown) | Common Ground (Pico Pin 3 - GND) | |
| Signal (Orange/Yellow) | GP13 (Pin 17) |
from machine import Pin, PWM, time_pulse_us
import time
# Pin Tanımlamaları
trig = Pin(15, Pin.OUT) # GP15 (Pin 20)
echo = Pin(14, Pin.IN) # GP14 (Pin 19)
servo = PWM(Pin(13)) # GP13 (Pin 17)
servo.freq(50) # Servo motorlar 50Hz frekans ile çalışır
# Servo Açı Ayarları (Kendi kovanıza göre kalibre edebilirsiniz)
KAPALI_POZISYON = 2100 # Çöp kovasının kapalı olduğu açı
ACIK_POZISYON = 4500 # Çöp kovasının açık olduğu açı
# Başlangıç durumu
servo.duty_u16(KAPALI_POZISYON)
print("Akıllı Çöp Kovası Başlatıldı. Kapak Kapalı.")
time.sleep(1)
# Başlangıçta motoru boşa alarak cızırtıyı kes
servo.duty_u16(0)
def mesafe_olc():
# Sensöre tetikleme sinyali gönder
trig.value(0)
time.sleep_us(2)
trig.value(1)
time.sleep_us(10)
trig.value(0)
# Yankı süresini ölç (Zaman aşımı: 30000 us)
sure = time_pulse_us(echo, 1, 30000)
# Eğer sinyal gelmezse veya hata olursa
if sure < 0:
return 999
# Süreyi santimetreye (cm) çevir
mesafe = (sure * 0.0343) / 2
return mesafe
while True:
try:
olculen_mesafe = mesafe_olc()
# Eğer okunan mesafe 2 ile 20 cm arasındaysa (el yaklaştıysa)
if 2 < olculen_mesafe < 20:
print(f"El Algılandı! Mesafe: {olculen_mesafe:.1f} cm -> Kapak AÇILIYOR...")
servo.duty_u16(ACIK_POZISYON) # Kapağı aç
# Kapağın açık kalma süresi (3 Saniye)
time.sleep(3)
print("Kapak KAPATILIYOR...")
servo.duty_u16(KAPALI_POZISYON) # Kapağı kapat
time.sleep(1) # Kapanması için bekle
# Kapanma sonrası motoru boşa alarak cızırtıyı kes (Stall önleme)
servo.duty_u16(0)
time.sleep(0.1) # Hızlı döngüden kaçınmak için
except Exception as e:
print("Sistem Hatası:", e)
time.sleep(1)