How to Fade an LED with Arduino analogWrite (Lesson #6)

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ก.ย. 2024

ความคิดเห็น • 28

  • @RohanRauf-uq1ky
    @RohanRauf-uq1ky 3 หลายเดือนก่อน +4

    His are genuinely far easier than other guys', go on unnecessary things, and are not even able to speak correct English. THANK YOU FOR THIS CONTENT KEEP IT UP!.

  • @SnakePicks
    @SnakePicks 8 หลายเดือนก่อน +5

    Just found your channel and am now hooked on your videos. These are perfect for a beginner like myself.

  • @lukemanning3825
    @lukemanning3825 ปีที่แล้ว +6

    thanks so much for this video, I was following another tutorial that used pin 9 without saying why and so not thinking the pin mattered had used pin 4 and couldn't work out why my LED was off half the time and on half the time. Really appreciate you actually explaining what you're doing so people like me can learn not just follow rote.

    • @Science.Buddies
      @Science.Buddies  ปีที่แล้ว +1

      Thanks, we're glad it was helpful! Be sure to check out the other videos in the playlist if you haven't already.

  • @SilentEmilie
    @SilentEmilie ปีที่แล้ว +2

    Thank you for these videos! I've just bought an Arduino and it's exactly what I need.

    • @Science.Buddies
      @Science.Buddies  ปีที่แล้ว +1

      Glad we could help! Check out our website (link in description) for cool projects you can do with an Arduino once you're comfortable with the basics.

  • @ingenierocivilizado728
    @ingenierocivilizado728 7 หลายเดือนก่อน

    This list of arduino videos is really useful and well explained. thank you very much!

  • @StoicOptim
    @StoicOptim 2 หลายเดือนก่อน

    These are all so awesome to learn! Thanks!

  • @manu50415
    @manu50415 ปีที่แล้ว

    May I have your advice. Accoding to the LED fading code
    /*
    Fade

    This example shows how to fade an LED on pin 9
    using the analogWrite() function.

    This example code is in the public domain.
    */
    int led = 9; // the pin that the LED is attached to
    int brightness = 0; // how bright the LED is
    int fadeAmount = 5; // how many points to fade the LED by
    // the setup routine runs once when you press reset:
    void setup() {
    // declare pin 9 to be an output:
    pinMode(led, OUTPUT);
    }
    // the loop routine runs over and over again forever:
    void loop() {
    // set the brightness of pin 9:
    analogWrite(led, brightness);
    // change the brightness for next time through the loop:
    brightness = brightness + fadeAmount;
    // reverse the direction of the fading at the ends of the fade:
    if (brightness == 0 || brightness == 255) {
    fadeAmount = -fadeAmount ;
    }
    // wait for 30 milliseconds to see the dimming effect
    delay(30);
    }
    From the code, the LED will fade up - down in 30 msec again and again. If I would like to have the loop like this >> fade up-down,30 msec---turn off 5 sec----fade up-down,30 msec again. How to modify the program? Thank you

    • @Science.Buddies
      @Science.Buddies  ปีที่แล้ว

      Hi - we're unable to provide advice on individual programming projects. Our tutorials are very hardware-focused, but if you search on TH-cam you should be able to find other more programming-focused Arduino tutorials on things like delays and loops that will help you accomplish what you want.

  • @castelmichel8670
    @castelmichel8670 11 หลายเดือนก่อน

    Thank you for your tutorials, brilliantly explained. I noticed you add a space between certain values, is it a rule to follow or is it to keep things neat? Thanks

    • @Science.Buddies
      @Science.Buddies  11 หลายเดือนก่อน

      Spaces don't affect the code, it's just to keep things neat visually (and a matter of personal preference to some extent).

  • @godlovesyou2243
    @godlovesyou2243 4 หลายเดือนก่อน

    Thank you sk much this heloed alot

  • @cadillacescalade5428
    @cadillacescalade5428 ปีที่แล้ว +1

    Hi how would I write this for a Alternatively flash ?
    I'm trying to create a night time traffic light

    • @Science.Buddies
      @Science.Buddies  ปีที่แล้ว +2

      If you just want the lights to flash and not fade, you just need the digitalWrite command, not analogWrite. Check out the other videos in our playlist and they should explain it.

  • @ProsperTeni
    @ProsperTeni 3 หลายเดือนก่อน

    I couldnt help but notice this video didnt have a tinkercad version. I went on to try it on tinkercad but it didnt work, any reason for that?

    • @Science.Buddies
      @Science.Buddies  3 หลายเดือนก่อน +1

      We just tried the Arduino "fade" example (File/Examples/Basics/Fade) in Tinkercad and it worked, but the fade can be a little hard to see in the animation. This video is almost two years old, but we probably skipped Tinkercad for this one because the fade is easier to see in real life.

  • @helenavont2987
    @helenavont2987 2 หลายเดือนก่อน

    I am looking for this effect, but with 4 lights preferrably at random. But i can not seem to find any instructions or code to make that work... does anyone know how i can do that?

  • @wynixcabantac7486
    @wynixcabantac7486 9 หลายเดือนก่อน

    How do i integrate this with a photoresistor so when light is face on the photoresistor it will fade?

    • @Science.Buddies
      @Science.Buddies  9 หลายเดือนก่อน

      We have an entire tutorial series linked in the video description, including a photoresistor tutorial here: th-cam.com/video/XwJQJnY6iUs/w-d-xo.htmlsi=5_8XT00xAJMNMMfd

  • @YouDontKnowMe210tx
    @YouDontKnowMe210tx 11 หลายเดือนก่อน

    is this C or javascript, which should i learn and are there any books you suggest i should learn c ? im aware of freecode camp and w3schools but i really want to learn c

    • @Science.Buddies
      @Science.Buddies  11 หลายเดือนก่อน +1

      Arduino is programmed in C/C++, not Javascript. We have our own tutorials (this is just one video in a playlist) but we can't really recommend one specific book or website over another.

    • @YouDontKnowMe210tx
      @YouDontKnowMe210tx 11 หลายเดือนก่อน

      Thank you@@Science.Buddies

  • @angela.8586
    @angela.8586 ปีที่แล้ว

    Thankyou!! But does this work with 6 led?

    • @Science.Buddies
      @Science.Buddies  ปีที่แล้ว

      Yes, the Arduino UNO has 14 digital I/O pins, so you can add more LEDs.

  • @Cheech157
    @Cheech157 5 หลายเดือนก่อน

    5:43

  • @Cheech157
    @Cheech157 5 หลายเดือนก่อน

    5:51