Python Tutorials – பாடம் 4 – Single LED Control With Single Pushbutton

ஒரு புஷ் பட்டன் ஐ பயன்படுத்தி ஒரு LEDஐ ஒளிர வைப்பது

Required Components

  1. LED-1 no
  2. 220 Ω Resistor-1 no
  3. 10 K Ω Resistor-1 no
  4. Pushbutton-1 no
  5. Bread Board-1 no
  6. Raspberry Pi Pico-1 no
  7. Connecting wires-1 Set

Circuit

Steps

  1. நாம் பயன்படுத்தும் உபகரணங்கள் சரியாக வேலை செய்கிறதா என்பதை உறுதி செய்து கொள்ளவும்.
  2. இரண்டு வகையான மின்தடைகளை எடுத்து கொள்ளவும் ஒன்று 10K மற்றறொன்று 220 Ohm.
  3. 220Ohm மின்தடையை LED உடனும் 10K மின்தடையை சுவிட்ச் உடனும் இணைக்க வேண்டும்.
  4. அந்த புஷ்பட்டன் ஐ Raspberry Pi Pico GP17 உடன் இணைக்க வேண்டும்.
  5. 220Ohm மின்தடையை LED + உடன் மற்றும் LED – ஐ GND உடன் இணைக்க வேண்டும்.
  6. 220Ohm மின்தடையை Raspberry Pi Pico GP16 உடன் இணைக்க வேண்டும்.
  7. புஷ் பட்டன் ஐ அழுத்தும் போது LED ஒளிர வேண்டும்.
  8. Python program ஐ சரி பார்க்க வேண்டும்.
  9. மின்சுற்றை சரி பார்க்க வேண்டும்.
  10. Python program ஐ ரன் செய்ய வேண்டும்.

Python Program

from machine import Pin
from time import sleep
led_pin = Pin(16, Pin.OUT)    # 16 number in is Output
push_button = Pin(17, Pin.IN)  # 17 number pin is input

while True:
  
  logic_state = push_button.value()
  if logic_state == True:     # if push_button pressed
      led_pin.value(1)             # led will turn ON
  else:                       # if push_button not pressed
      led_pin.value(0)   

Leave a Reply

Your email address will not be published. Required fields are marked *