Interfacing HS0038A2D with raspberry pi pico

 # Toggling an led/Relay with pushbutton and HS0038A2D


from machine import Pin# Import Pin class from machine module

import time# importing time module

button = machine.Pin(16,Pin.IN,Pin.PULL_UP)#declaring a variable button and assign as an INPUT,PIN16 PULLED UP INITIALLY(GPIO 16 and GND)

led = Pin(17,Pin.OUT)# declaring a variable led and assign as an OUTPUT the GPIO Pin 17 

while True:

    if button.value()==0:

        led.toggle()

        time.sleep(0.5)



Comments

Popular posts from this blog

4 Stage Timer With DS3231RTC Module.

Interfacing KY038 sound sensor with Raspberry pi Pico

Interfacing MQ2 Gas & Smoke Sensor With Raspberry Pi Pico