Controlling a LED using a Push button and Arduino Uno

Поделиться
HTML-код
  • Опубликовано: 6 авг 2022

Комментарии • 21

  • @harukills
    @harukills Год назад +11

    You dont actually need an adruinno to do this mechanism, but i guess there's other form of uses

    • @dktechs
      @dktechs  Год назад +7

      I totally agree with you but here my intention was not to switch on and off a LED you can do this without any switch or push button also,here my intention was to read a digital input and control digital output, that's all.

  • @efrenvillariasa6575
    @efrenvillariasa6575 9 месяцев назад +4

    Can you give me the code the one that can continues the on and off thank you

  • @Expatriate1977
    @Expatriate1977 Год назад +2

    Thank you!

  • @memelate9624
    @memelate9624 Год назад +5

    bro if u didn't use bool it cud have worked
    if(btnsts == HIGH)
    digitalWrite(ledpin,LOW)

    • @dktechs
      @dktechs  Год назад +1

      Bro I didn't get you...
      Any logic in c or c++ you can write in thousands way...
      What I wanted accordingly I achieved my target and whatever I wrote in code you can write in hundreds ways.
      But sorry bro exactly I am not getting what do you want to say.

    • @memelate9624
      @memelate9624 Год назад +2

      ​@@dktechs
      nvm
      it shud fit ur taste

  • @davariz
    @davariz 8 месяцев назад +1

    Estou tentando achar um codigo que eu teria que clicar uma quantidade de vezes no butao (dentro de um espaco de tempo) para o led acender por uma quantidade de tempo

    • @dktechs
      @dktechs  8 месяцев назад

      You have to use timer and counter to achieve this.When button pressed increment counter by 1 as well as read timer value. Say if you want to turn ON LED for 5 seconds when two times button pressed in one second then if you counter value is two in one second turn ON LED and run timer for 5 seconds after 5 seconds turn OFF LED.

  • @rubiksbest171
    @rubiksbest171 Год назад +4

    Hi.
    May I know how much resistance is that resistor?

    • @dktechs
      @dktechs  Год назад +5

      220 ohm

    • @rubiksbest171
      @rubiksbest171 Год назад +2

      @@dktechs thanks!

    • @dktechs
      @dktechs  Год назад +2

      You can use any values between 150 and 400 to protect your LED from high current if you want to explore more about LED resistor you can checkout this video ruclips.net/video/SIVfg30_KcU/видео.html

  • @Learningontop
    @Learningontop 11 месяцев назад +1

    Sir I want that when my button press for how many time no matter but by output will turn off after 30 second so what I do.

    • @dktechs
      @dktechs  11 месяцев назад +1

      So many ways to perform this one of them you can use a timer when you press a button start 30 seconds timer and make output High and stop reading button,when 30 seconds timer stopped you can make output low and start reading button.For this you use a flag to keep track of time or timer ISR

  • @efrenvillariasa6575
    @efrenvillariasa6575 9 месяцев назад +1

    I follow your code but doesn't work my Arduino app

    • @dktechs
      @dktechs  9 месяцев назад

      Doesn't work means it's not compiling in IDE or hardware is not working?

  • @prashantk6823
    @prashantk6823 8 месяцев назад +1

    Which resistor use?

    • @dktechs
      @dktechs  8 месяцев назад

      For pull up or pull down you use between 1k and 4.7k.