Tutorial 10: Fade an LED: Arduino Course for Absolute Beginners (ReM)

แชร์
ฝัง
  • เผยแพร่เมื่อ 9 ม.ค. 2025

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

  • @programmingelectronics
    @programmingelectronics  4 ปีที่แล้ว +3

    ****If you like this, I think you'll like the premium Arduino training we offer. You can check it out here**** bit.ly/3lHyzcB

  • @anthonyschroeder3611
    @anthonyschroeder3611 5 ปีที่แล้ว +4

    The instructor is probably one of the best teachers. Not only of micro controllers but in the sense of teaching as a gift. He is very intuitive and assumes nothing of the viewer. He does not come off as condescending or pretentious. He uses technical language only in instances that a new learner of micro controllers would need to know to receive a solid foundation in this field of electronics. He does not overwhelm me with too much technical jargon that might prove to confuse me more than help me. He adds DIY challenges that fit very well into his lesson and poses great insight for the viewer. His voice is confident but not alarming and he has a way about explaining arduous concepts in the most relatable fashion. However I find his most seducing characteristic is his dry humor. He adds ridiculous comments in his explanations/instructions with the utmost sincerity that I often wonder if he is being funny on purpose or just weird. Either one or both is right with me. Teacher Dude....I may not know you, or even know your name. But I love you. You make this easy, fun, and bring joy into so many lives. Thanks.

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

    I've dug through many of the Arduino Tutorials and these are hands down the best I've found. A step by step walk through of the code with a little off humor (crystal mouse). I learned a lot from another guy out there but when I found out you can just "map" a range and didnt have to learn algebraic slopes I was a little upset over wasting so much time. This Series leads you down efficient and relevant pathways.
    Also, Check out the Milli's tutorials, much better way to program. I do wish there was one on Switch/Case. I found Switch/Case elsewhere. Switch/Case and Milli's transformed how I program.
    Thank You Programming Electronics Academy!

    • @programmingelectronics
      @programmingelectronics  3 ปีที่แล้ว

      Thanks so much for your words! Glad you found this series helpful!

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

    Hands down the most informative tutorial regarding arduino ive found. Working to build a CNC metal lathe using Arduino. You make learning the code language very easy. Thank you!

    • @programmingelectronics
      @programmingelectronics  9 ปีที่แล้ว

      +Cody Crusenberry Thanks so much for that! I hope you find our other videos helpful also.

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

    Maybe you already heard this from others, but the slide at 5:00 in the video lists the PWM pins as 3,5,6,10&11, you need to add pin 9, as used in the tutorial.

  • @bensibeijn7137
    @bensibeijn7137 10 ปีที่แล้ว +9

    He' man so far I a have seen a lot of videos on the topic arduino.
    But I agree with the rest of the comments.... you are one of the best. Explicit and repeating some of the concepts....which makes the brain remember. Also your voice and speech is suitable for this job i.e clear, no mumble jumble.

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

    Thank you sooooo much! I have been staring at the codes for few hours and could not figure out the dimming part....with your thorough explanation, I finally understood it. :) Thank you!!!

  • @ahmedhzaa
    @ahmedhzaa 10 ปีที่แล้ว +7

    You are the best teacher ever and i have learned a lot from you , thank you very much from Egypt

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

    Absolutely excellent series! I'm a total beginner to electronics and coding (bar a bit of basic in the 80's), and your explanations for how everything works and why are easy to follow. Thanks very much, my arduino and I are following with interest, cheers!

  • @romanmaikovych1457
    @romanmaikovych1457 9 ปีที่แล้ว +28

    Very, very useful tutorial. Good explanation technique and the orator as well

    • @programmingelectronics
      @programmingelectronics  9 ปีที่แล้ว

      +Roman Maikovych Thanks for watching!

    • @anthonyrossetti7509
      @anthonyrossetti7509 7 ปีที่แล้ว

      totally lost me so what would the code be if i want to have an LED fade on and then stay at 100% brightness for a specified number of second then fade off , also have a second LED fade on as the first is fading off
      and how many pins can i use PWM on on an arduino mini , can i use analog pins for PWM too? this is the sketch for my halloween project ,which is blinking these for leds eye lights
      postimg.org/image/4d6sw2u6z/
      void setup() {
      pinMode(2,OUTPUT);
      pinMode(3,OUTPUT);
      pinMode(4,OUTPUT);
      pinMode(5,OUTPUT);
      pinMode(6,OUTPUT);
      pinMode(9,OUTPUT);
      pinMode(10,OUTPUT);
      pinMode(11,OUTPUT);
      pinMode(A0,OUTPUT);
      pinMode(A1,OUTPUT);
      pinMode(A2,OUTPUT);
      pinMode(A3,OUTPUT);
      }
      void loop() {
      digitalWrite(2,HIGH);
      digitalWrite(3,LOW);
      delay(5000);
      digitalWrite(2,LOW);
      digitalWrite(3,HIGH);
      delay(5000);
      digitalWrite(4,HIGH);
      digitalWrite(5,LOW);
      delay(6000);
      digitalWrite(4,LOW);
      digitalWrite(5,HIGH);
      delay(6000);
      digitalWrite(9,HIGH);
      digitalWrite(6,LOW);
      delay(6000);
      digitalWrite(9,LOW);
      digitalWrite(6,HIGH);
      delay(6000);
      digitalWrite(A1,HIGH);
      digitalWrite(A2,LOW);
      delay(4000);
      digitalWrite(A1,LOW);
      digitalWrite(A2,HIGH);
      delay(4000);
      digitalWrite(A0,HIGH);
      digitalWrite(A3,LOW);
      delay(4000);
      digitalWrite(A0,LOW);
      digitalWrite(A3,HIGH);
      delay(4000);
      digitalWrite(10,HIGH);
      digitalWrite(11,LOW);
      delay(4000);
      digitalWrite(10,LOW);
      digitalWrite(11,HIGH);
      delay (4000);
      }
      how can i edit this so that they blink at the same intervals but just fade off and on instead of blink?

  • @NeonblueIndustries
    @NeonblueIndustries 5 ปีที่แล้ว +3

    Thanks Man! You have a great natural gift of teaching. This is my favorite Arduino tutorial channel!

  • @HuyNguyen-gl4wl
    @HuyNguyen-gl4wl 4 ปีที่แล้ว +2

    These tutorials are so helpful, I like how you explain those details, I'm always struggling with understanding what is going on between the code and how it functions. Gonna subscribe to the channel and a big thank you from Canada!

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

    I got the 2560 kit and was about to give up until I found these tutorials. Thank you.

  • @jezzabellaStudio
    @jezzabellaStudio 8 ปีที่แล้ว +7

    Thanks so much for putting together a fantastic tutorial! Really guided me through, you even got the techy stuff through to me! (Sometimes it's a challenge). Huge thumbs up to you and your team. DIY computing is the bomb.

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

    Clearly explained with perfect pace, great graphics and pleasant voice. Top marks!
    Thankyou so much
    :-)

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

    Just Amazingg!! Best video on TH-cam and best explaination in simplest manner!!

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

    This has helped me a ton amount. You are a talented teacher. Keep up the good work.

  • @getreal155
    @getreal155 6 ปีที่แล้ว

    Very good tutorial. A real teacher at work. Each section divided in small steps making it very easy to digest.
    Little slow for my taste some times but better slow than too fast.

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

    Now that's what I call clever!! Amazing use of IF statement

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

    Your tutorials are amazing, for a noob like me some parts needs to be this slow for it to sink in. :)
    Thank you very much!

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

    Sir u explain very well but I don't understand when do we need to declare our hardware in the Void Setup. For example you had declared the LED but u didn't declare the potentiometer

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

    These are excellent tutorials, I'm about to start my first project and I'm learning all I can! I have a few questions about resistors though. Why do you need the resistor, how do you know when you are going to need a resistor, and how do you know what resistance you need?

  • @TaManThanawat_Tah
    @TaManThanawat_Tah 7 ปีที่แล้ว

    Thank you, for your very easy to understand tutorials. This is my first try to coding arduino and it success by your video.
    I tried to add some thing to the code to make it able to follow the value of variables.
    void setup() {
    // declare pin 9 to be an output:
    pinMode(led, OUTPUT);
    Serial.begin(57600); //To show variable value in serial monitor (change this option in Serial monitor window too)
    }
    // 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 = 255) {
    fadeAmount = -fadeAmount;
    }
    // wait for 30 milliseconds to see the dimming effect
    delay(100);
    Serial.print("Fadeamount: "); //Print text
    Serial.print(fadeAmount);
    Serial.print(" Brightness: ");
    Serial.println(brightness);
    }

  • @thapaharis
    @thapaharis 7 ปีที่แล้ว +3

    best tutorial that i have found on youtube. thank you and have a great day

  • @heighwaya2
    @heighwaya2 11 ปีที่แล้ว +4

    That was the best tutorial on Arduino code I've watched, Thank you

  • @David-rc8us
    @David-rc8us 9 ปีที่แล้ว +1

    Hi Again
    Thanks for you Arduino tutorial for absolute beginners .I have completed 01 to 10 and I have done all of the challenges that you set. That is where I learnt the most. Get your hands dirty so to speak.
    Your on line courses look brilliant .Would one of your courses be OK for some who just has an interest or a hobbyist not to heavy . I have only had my Arduino for 6 day.I dint know what one was this time last week! Thank you !
    Anyway Thank you very much for a brilliant course .
    Best Regards
    David UK

    • @programmingelectronics
      @programmingelectronics  9 ปีที่แล้ว

      Thanks +David dave ! I try to keep the online course as newcomer friendly as possible, so, although utterly biased, I would say it is probably a great fit.

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

    Excelent work, in 2 hours I make 7 simple circuits and learn howit's function!!! thanks you!!!!

  • @44mod
    @44mod 7 ปีที่แล้ว

    These Tutorials are great and thank you. I did the challenges and everything is working as it should with the two lights. Thanks for the hint that helped a lot. I wanted to take it one step feather and change the delay for each light and that is where i hit a snag. I wanted to do a delay on led pin 9 @ 30 and a delay on led2 pin 3 @ say 60 or 5 or 25.

  • @davidv313
    @davidv313 10 ปีที่แล้ว +3

    By far the best tutorials available. Thanks :)

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

    So happy I found your tutorials. Very helpful, Thanks!

  • @the_hailing_god
    @the_hailing_god 7 ปีที่แล้ว +3

    You are an amazing teacher !!! Need more tutors like you in this world !!

  • @gijs3000
    @gijs3000 5 ปีที่แล้ว

    for question 3, you don't need to write any extra code to fade multiple LED's at the same time. Just put an extra led in the circuit, and your good. And btw, great series :)

  • @zzzzzz...9902
    @zzzzzz...9902 8 ปีที่แล้ว

    It works! It works! The arduino works!
    eh eh, you probably thought I was going to say dislike button works. The truth is I love this guy, great tutorial.

  • @PANTYEATR1
    @PANTYEATR1 9 ปีที่แล้ว

    I've always wanted to have a car alarm that had a "beacon" type LED to warn others that the car was equipped with an alarm... this fading LED is just what I'm looking for!

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

    This is brilliantly presented

  • @RichardHBaum
    @RichardHBaum 10 ปีที่แล้ว

    Great tutorial, thanx for posting. It's nice to have someone like you to take the time to explain examples. I'm new to this Arduino world. I pretty well understand the software, but have no/little hardware experience or exposure. I am unable to upload the code example because my Uno is on COM3 by virtue of Windows8 automagically recognizing the device and putting it there. However, your code example seems to default to COM1 and I don't know how to re-match the code or the COM port. Help please? thanx, Richard

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

    Great tutorials thank you - just one point though which got me for a while - you mention in the key points about the analogWrite () function can be used with pins 3, 5, 6, 10 & 11 but you use pin 9 in your example. Was this in error?

  • @a.saeedel-shazly5867
    @a.saeedel-shazly5867 8 ปีที่แล้ว

    Thanks very much ...the challenge had been done,,,,if we increase the "fadeamount" or decrease the "delay" the LED brightness will change rabidly

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

    Great videos. i'm loving following along. took CompSciJava in high school 10 yrs ago, so i generally know syntax and such, but this guy is a good educator, my teacher was a GREAT coder, and a "qualified" educator,
    either that or now i'm just soo interested in coding to control hardware, but wasn't very fun for me to code a black and white 8bit game of pong for a couple weeks, then go home and play XBOX lol

  • @iBielik
    @iBielik 7 ปีที่แล้ว +12

    Thank You.... just thanks you :) best tutorial in whole internet.

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

    Quick question..the (int led = 9 ) assigns pin 9. Why don't the others (int brightness = 0) assume we are assigning pins and not designated values??? Is it because we didn't assign them to a pinMode INPUT or an OUTPUT. Never mind answered my own question :)
    By the way. Best Arduino tutorials I have come across!!!

    • @programmingelectronics
      @programmingelectronics  10 ปีที่แล้ว

      Hi Klay, Great question!
      One additional thought, pins are by default set as inputs. So even if you do not set a pin using the pinMode(pin, INPUT), it can still act as an input.
      So, if you set brightness = 5, and then referenced brightness in digitalWrite() i.e.
      digitalWrite(brightness, HIGH);
      As long as you had an LED at pin 5, it would turn on.
      So the variable doesn't really care what you use it for. The value assigned could be a pin, or the brightness, or the amount to fade, or whatever. An integer variable only cares that the number assigned to it is an integer, after that - we can use that variable however we want.
      Hope that makes a little sense. Have a good one!

  • @cuvarsnova
    @cuvarsnova 8 ปีที่แล้ว

    To test I use the Arduino and I will incorporate nano into what I'm
    doing now. I see that the fading can be used 3,5,6,9,10 and 11 digital
    pin, and I need 8 pins. Can some of analog pin used for missing 2 fade
    possibility. Thanks in advance and I wish you a nice day~

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

    All these tutorials are very helpful.

  • @paulhindley3773
    @paulhindley3773 3 ปีที่แล้ว

    Very good video, little confused though that it says the fadeAmount changes to a negative once at 255 to bring it back down but when it goes down and hits 250 the if statement it ruled out. So why does fadeAmount not go back to value outline in declaration when if function is not is use.

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

    Best tutorial for beginners coding.

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

    boss you are amazing tutor... and one of my reasons to learn arduino interestingly

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

    ur tutorials are awesome sir

  • @kilomikesierra7840
    @kilomikesierra7840 7 ปีที่แล้ว

    Thanks for great video. Helped me a lot
    I just wonder few things about PWM
    1. Is it right that PWM pin has 0~255 phases to send voltage, and non-PWM has only 0 and 255 phases?
    2. Is it right brightness of LED or other light-emitting things is decided by PWM?

  • @cadillacescalade5428
    @cadillacescalade5428 8 หลายเดือนก่อน

    Hi, I've been following and watching your videos here in order,
    I'm still learning but what I wanna know is how to fade alternately
    Could you give me an idea ?

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

    This is one of the best tutorials I have ever seen.
    I have 3 questions:
    1. Could you have initialized your variables within the void setup block? (does it make a difference?)
    2. How do you know to use a 220 resistor?
    3. I tried to add another LED and it didnt work. All I did was add "int led2 = 3" below the first one, then added "pinMode (led2, OUTPUT)" to the setup block, then added "analogWrite(led2, brightness)" in the loop block. The code compiles without error. I then plugged a 220 ohm resistor into pin3, plugged the short LED leg into the breadboard, and attached the long LED leg to the resistor. Nothing happened. Is it the code, or something physical? The only thing I'm wondering about is that the first LED is connected to the ground on the UNO, while the 2nd LED is not grounded...?

    • @disappear1234
      @disappear1234 8 ปีที่แล้ว

      +snipes0009 the 2nd need to connected into ground and you need to change most the code not just those i got min to blink instead of fade
      */
      int leds = 7; // the pin that the LED is attached to
      int brightnesses = 0; // how bright the LED is
      int fadeAmounts = 3; // how many points to fade the LED by
      int led = 9; // the pin that the LED is attached to
      int brightness = 0; // how bright the LED is
      int fadeAmount = 4; // 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);
      pinMode(leds, OUTPUT);
      }
      // the loop routine runs over and over again forever:
      void loop() {
      // set the brightness of pin 9:
      analogWrite(led, brightness);
      analogWrite(leds, brightnesses);
      // change the brightness for next time through the loop:
      brightness = brightness + fadeAmount;
      brightnesses = brightnesses + fadeAmounts;
      // reverse the direction of the fading at the ends of the fade:
      if (brightness == 0 || brightness == 255) {
      fadeAmount = -fadeAmount ;
      }
      if (brightnesses == 0 || brightnesses == 255) {
      fadeAmounts = -fadeAmounts ;
      }
      // wait for 30 milliseconds to see the dimming effect
      delay(30);
      }

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

      In order for your second LED to fade you would have to use
      pin 3, 5, 6, 9, 10 or 11.
      Remember in the comment there is
      "On most Arduino, the PWM pins are identified
      with a "~" sign, like ~3, ~5, ~6, ~9, ~10 and ~11."
      You are using pin 7 which is not setup as a PWM.
      On the Arduino UNO you should see a note "DIGITAL (PWM~)"
      right below pins 0-7 which shows which pins are setup as PWM.
      Here is my code:
      /*
      Fade
      This example shows how to fade an LED on pin 9
      using the analogWrite() function.
      The analogWrite() function uses PWM, so if
      you want to change the pin you're using, be
      sure to use another PWM capable pin. On most
      Arduino, the PWM pins are identified with
      a "~" sign, like ~3, ~5, ~6, ~9, ~10 and ~11.
      This example code is in the public domain.
      */
      int led1 = 9; // the PWM pin the LED is attached to
      int led2 = 3; // the PWM pin 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(led1, OUTPUT);
      pinMode(led2, OUTPUT);
      }
      // the loop routine runs over and over again forever:
      void loop() {
      // set the brightness of pin 9:
      analogWrite(led1, brightness);
      analogWrite(led2, 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 = 255) {
      fadeAmount = -fadeAmount;
      }
      // wait for 30 milliseconds to see the dimming effect
      delay(30);
      }

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

      Thanks

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

    Without thinking, thanks for your tutorials. I learned too much. Just a question, what is the PWM frequency of analog outputs (or what is the length of the cycle)? Can I write my own code to make all digital pins act like analog outputs?

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

    Why did you use 220 ohm resistor?

  • @rishi0299
    @rishi0299 5 ปีที่แล้ว

    Hi, very well understood, thanks for the video! What if I want to fade multiple LEDs at once and not rewrite the code everytime for each LED?
    Thanks

  • @lassinpelituokiot5381
    @lassinpelituokiot5381 5 ปีที่แล้ว

    Hi! What if I would use fadeAmount 6 for example? 255/6 is decimal number. Do I need > and < instead of equals? Thanks for your good video and sorry for bad language.

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

    Good explanation 👨🏼‍🏫

  • @sedamezhieva9846
    @sedamezhieva9846 7 ปีที่แล้ว

    Hello, I have a question, in the 3rd challenge, why did we not have to create a new pinMode line to declare the 2nd pin as an output as well? Or is everything declared to be an output automatically and thus this line is optional? Thanks for help!

  • @lotfiboutebal233
    @lotfiboutebal233 6 ปีที่แล้ว

    Ho there,thank you. For what you ve done , i have a question : what do the pwm really mean i am confused betwwen the modulation of the time that 5v is applied and between the amount of the voltage that is applied as we ve seen in the voltage read or the single led brightness. Thnks

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

    To make a smoother one set fadeAmount to 1 and delay to 3 :p thx mate ur a great tutor!!

  • @pong301275cmu
    @pong301275cmu 8 ปีที่แล้ว

    You gave us a nice tutorials and made it easy to learn.
    Thank you guy,

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

    thank you for this amazing piece of leason. just one question when the loop goes bellow 0 and it's (-1)*(-5) how is it not continues to stay -5 instead it becomes permanent +5 after this operation. just a lame question I know but it bugs me off. it meets Condition of the "if" statement so should stay as negative five.... just get my head round it. please help uneducated guy understanding 😊

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

      This a great question, and it takes a while to grasp I think. If you remember that the variable that holds the fadeAMount value changessign every time through a complete loop:
      so the calculation goes
      (-1)*(5) = -5
      (-1)*(-5) = +5
      (-1)*(5) = -5
      (-1)*(-5) = +5
      The sign on the fadeAmount variable flip-flops. Hope this helps some!

    • @rafeldabek
      @rafeldabek 8 ปีที่แล้ว

      Programming Electronics Academy .of course! it's in circle hence "loop". all right now it makes sense. lol. I'm sorry. I said it might look like a daft question 😊. once loop is over it returns to the first command so the process restarts over nd over again. thank you again I'll be on it soon to test it and hopefully modify for future projects. peace out

    • @sasnasunder5748
      @sasnasunder5748 8 ปีที่แล้ว

      Programming Electronics Academy could you please tell me which song was that??

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

      heyyy sasna.... the song is bonus beat blast 2011

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

      Thank you so much.finally found this.

  • @guillermoisidoro4060
    @guillermoisidoro4060 8 ปีที่แล้ว

    Hi, you have solved to me a lot of questions. You're explain sketch for every component. Now, i'd like to know how to integrate all the "ingredients" in one Sketch : for example how to join a Arduino Mega with buzzer alarm, sequential leds with ultrasonic sensor Us-100, and I2c screen. I'm trying to do but I'm just receiving a lot of error messages. one of them came from IDE examples Servo Sweep- I t says "error compiling for mega arduino" I'll apreciate any help. Have a nice day!

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

    7:04 then why multimeter show different voltages respective to 255 ??

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

      Great question - just so I follow - are you asking why your multimeter measures a voltage other than 5 at a pin you are PWMing? If that is the question, this answer might help:
      forum.arduino.cc/t/what-does-a-voltmeter-read-on-a-pwm-pin/674800/4

  • @TheJavaSync
    @TheJavaSync 3 ปีที่แล้ว

    5:52 - why pin9, there isn't there?

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

    Hey , I have a doubt in pulse width modulation section. While varying the second argument in analogWrite function , the varying value is power output voltage (0 to 5v) or time for which 5v is got as power ouput. Thanks in Advance.

  • @railbuilderdhd
    @railbuilderdhd 7 ปีที่แล้ว

    If I add an array of LEDs can I control the brightness of each LED separately or would they only be one brightness. Can the array fade each LED at a different fade rate or would I need to loop for each LED?

  • @Skandawin78
    @Skandawin78 7 ปีที่แล้ว

    I'm trying to fix a midi keyboad which is not sending midi anymore and not recognized by my PC when connected( have latest drivers installed) . hoping to make it work again using arduino. it has 25 keys , 2 wheels and 8 knobs. just ordered arduino uno kit and couple of shift registers . looking for a tutorial to help me fix my keyboard.

  • @shashwatpandey3862
    @shashwatpandey3862 6 ปีที่แล้ว

    can i use pin 13 instead of 9 as it has an inbuilt resistor and i dont have to use an extrA resistor and change the code accordingly ofcourse ?

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

    First of all- your tutorials are GREAT!
    Second of all- I’m having a rough time understanding something. I understand that when brightness = 0 or 255, fadeAmount is multiplied by a -1, and would cause brightness to increase or decrease by a value of 5. But as soon as brightness goes from say 255 to 250, how does the brightness continue to decay towards zero? I’m just wondering because as soon as brightness = 250, the boolean operator is not a true statement (i.e. brightness ≠ 0 or 255). So how come brightness doesn’t immediately go back to 255? I’m sure this is something simple, but I’m just not catching it.
    Thanks a lot!
    Mike

    • @TheMensel
      @TheMensel 9 ปีที่แล้ว +3

      Michael Wasiukiewicz I hope this helps:) When the loop is run through again the fadeAmount is still -5 because the statement is not true. So brightness= brightness + fadeAmount will be 250 - 5 which is 245. And after that 245 - 5 etc.

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

      Mendel Engelaer Thanks a lot- that helped!

    • @shutdahellup69420
      @shutdahellup69420 7 ปีที่แล้ว

      Michael Wasiukiewicz just to clarify,, the value is remained unchanged after a condition has taken place unit new condition is true, the 'if' function only changes the value *if* the condition is true else it remains the same which is -5 in that case :)

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

    Really appreciate the info, but I'm a bit confused on how you are choosing the LED and resistor. Since LEDs have different specs, they would require different resistors based on the input voltage. First, what is the upper voltage limit of the Arduino. Second, are you using this upper limit and the specs on your LED to figure the correct resistor? What is the LED you use rated for? I have a variety of LEDs that range from 1.7V at 20ma to 3.3V at 30ma or even higher ones. Should all this be taken into consideration? I hate to burn out LEDs. :) Thank you!

    • @programmingelectronics
      @programmingelectronics  10 ปีที่แล้ว

      Steampunked Out All great questions.
      On a digital pin, the max output voltage will be about 5 volts. Since most LEDs will drop between 1.7 to 2.1 volts depending on the color and are generally specified at 20 mAmps of current than I am very comfortable swagging the resistor value at 220 Ohms because it will usually keep you well within the current limit for most LEDs.
      If you want optimal performance for your specific LED then it would make a lot of sense to match the resistor value so you could get spot on (or close as possible) to the recommended current.
      Hope this helps some - Best of luck!

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

      Open Source Hardware Group
      Very helpful! Thank you! :)

  • @charliem5b
    @charliem5b 11 ปีที่แล้ว

    You are the best. Your tutorial rocks well done

  • @exerdragon3349
    @exerdragon3349 4 ปีที่แล้ว

    Hello,
    I was wandering if there was a way to fade the led to 255 at first and then to a mid value, like 150.
    I am trying so hard with what I know and the best that I achieved is the led to fade to 255 and then just going straight to a mid value.
    if (brightness = 255) {
    (fadeAmount = -fadeAmount);
    delay(500);
    (fadeAmount = fadeAmount);
    delay(500);
    I thinked that it would have started to fade out for 500ms and then again up for another 500ms but it didn't work, any help?

  • @zekeriasvarg530
    @zekeriasvarg530 7 ปีที่แล้ว

    If I want the diod to dim to max and then stay at max until an input value change from a source, say ultra sound input, simple line of code to add in?

  • @NickPetricci
    @NickPetricci 9 ปีที่แล้ว

    Really nice! Is there a method to change the frequency of the fade? Maybe using a potentiometer.. Do you know any ideas for the code?

    • @programmingelectronics
      @programmingelectronics  9 ปีที่แล้ว

      Hi +Nick Petricci, That is a great question!
      If you are familiar with analogRead() and also with hooking up a potentiometer to an analog pin, than you can feed the the output from analogRead directly into the delay function.
      something like...
      delay( analogRead(A0) );
      Best of luck.

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

      +Open Source Hardware Group Thank you! I'll try ;)

  • @mitchellazevedo5084
    @mitchellazevedo5084 11 ปีที่แล้ว

    wow good job. ive got a tutorial on this but this one is way better. keep it up!

    • @programmingelectronics
      @programmingelectronics  11 ปีที่แล้ว

      Thanks for the kind words! This video is actually a redo of some older tutorials I had done once I got some nicer screen capture software and a semi decent microphone.

  • @bhargavdayal8595
    @bhargavdayal8595 4 ปีที่แล้ว

    In the graph the red line shows voltage and the black line shows the time taken for that voltage.
    Am i right? .

  • @JimiTip
    @JimiTip 6 ปีที่แล้ว

    Is the intro song an official song? If so whats the name? Thanks

  • @theoldsasquatch
    @theoldsasquatch 11 ปีที่แล้ว

    Hey, I love these tutorials and the challenges are great also. I understand they way you teach. Thank you.
    I was just wondering, in this tutorial you mention all of the pins that have PWM but you do not mention pin 9 (which I believe on the UNO has PWM). Pin 9 also being the one that we are doing PWM with here. Maybe I am missing something or it is assumed we would recognize 9 as a PWM pin because we are currently using it haha. Either way wanted to mention it. Very excited for the rest of these tutorials.

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

      James - great point! I miss the very pin that I am demonstrating using in the video - thats pretty funny :)

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

    in the newer versions of the IDE, in the fade sketch, it has (brightness = 255) as opposed to what your version which has (brightness == 0 || brightness == 255). they seem to do the same thing, but what would be the reason for the change? is one better than the other?

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

      Great question! The new version is better. In one of the challenges in the course, I beleive we talk about why. Say for example, the brightness variable is set to the number 7. Even when the value of the brightness variable exceeds 255, the condition situation is not met in the == example, because multiples of 7 never = 255 (they exceed it, but don;t equal it), and so the fade amount variable does not change sign.
      i hope that makes some sense. Thanks for this great question.

    • @seanofromct246
      @seanofromct246 7 ปีที่แล้ว

      @ProgrammingElectronicsAcademy So is it a "greater than" and "less than" statement instead of an "equals" statement? BTW thanks for the amazing tutorials.

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

    I looks like pin 9 is now part of PWM? (it's used in this video, but is not part of the listed pins that have PWM).

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

      Thank you for the explanation of PWM, btw. Just found your content and I appreciate it!

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

      Thanks!

  • @KhalandarNawalSheikh
    @KhalandarNawalSheikh 8 ปีที่แล้ว

    Thanks a lot...
    It was very useful.
    But can you just say why 255 was used as the upper limit, is that because it's 1/4th of max brightness (5V) ?

    • @NtotheO
      @NtotheO 8 ปีที่แล้ว

      It's 8 bit which means there are 2^8=256 levels (0 to 255, counting the zero).

  • @TeamTEOR
    @TeamTEOR 8 ปีที่แล้ว

    How would I do this to work with 12 LEDs and have them fade in a independently and in a random pattern?

  • @harshitrajput6865
    @harshitrajput6865 7 ปีที่แล้ว

    Great lectures!
    I have a doubt. I changed the fadeAmount to 2,3,4,6 and every time the Led goes to its max brightness, then goes off and then again gains brightness. Why is this happening?

  • @thapaharis
    @thapaharis 7 ปีที่แล้ว

    is it necessary to keep resistor? i tried one without resistor, it worked but when i used a resistor it didn't. i don't know what went wrong

  • @Redstoneghost133
    @Redstoneghost133 8 ปีที่แล้ว

    Hey, I was wondering how would you would code it to do multiple leds fade in and out?

  • @BenTheKidd
    @BenTheKidd 4 ปีที่แล้ว

    I tried to do 2 alternating led's using this basic ideas however after about a minute the cycle speeds up and then just doesn't perform the sequence properly. Anyone have any insight?

  • @8907raptor
    @8907raptor 9 ปีที่แล้ว +4

    Thank you for the good Tutorial =)

  • @flavourcloud
    @flavourcloud 8 ปีที่แล้ว

    how does one go about calculating the necessary delay time at the end of the loop?

  • @TeeGiang
    @TeeGiang 10 ปีที่แล้ว

    thanks for the explanation, how would you fade 2 leds?

    • @thomcomstock278
      @thomcomstock278 9 ปีที่แล้ว

      +Manas Deore That was my challenge to myself - to have the two LEDs alternate. It took me a couple of tries, but I succeeded.

  • @derektran2352
    @derektran2352 6 ปีที่แล้ว

    Thank you! This exactly what I needed!

  • @KP-kt4lw
    @KP-kt4lw 10 ปีที่แล้ว +1

    Is there a way to give only one naming for multiple leds? for example : int leds = {3,5,6,9,10,11}

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

      Great question - yes, it would be a data structure called an Array. An Array can hold only one datatype, in your example, it would look like something like this:
      int LED_Array[] = {3,5,6,9,10,11};
      arduino.cc/en/Reference/Array

    • @KP-kt4lw
      @KP-kt4lw 10 ปีที่แล้ว

      Open Source Hardware Group Great thanks!

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

    Very well explained, thanks

  • @VaibhavGautamIndia
    @VaibhavGautamIndia 10 ปีที่แล้ว

    Hi, I've been following all your tutorials and I really like them but ca you please explain me hot to choose correct resistor for a particular LED or potentiometer or any other device. After a small research I found that it can be calculated with the help of ohms law but still I am not getting it. For example if the LED is of 2.2V connected to arduino then which resistor to use to make sure that Arduino and the connected device(LED) in this case remains safe.
    Because according to Ohms law if voltage for LED is 2.2V and it works on 0.02A (or we can say 20mA) the the resistance should be 110Ohms. then why we have used 220Ohms resistance?
    Thanks in advance :)

    • @akashsharma-vc6dt
      @akashsharma-vc6dt 10 ปีที่แล้ว

      it's (5-2.2)V/0.02A=140ohms i.e 2.8V should be dropped out of 5V and and its safe to use the resistor with approximately 1.5 times the calculated resistance i.e nearly equal to 220 ohms. This is done so that the resistor safely tollerates 0.02A current and the voltage doesn't exceed the maximum voltage range i.e 2.2 in this case

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

    can we use analogwrite function on both A0- A5 and (3,5,6,10,11) pins ?

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

      Great question! A0 - A5 cannot be used with analogWrite. But you can use them with analogRead!

  • @DanCoastie
    @DanCoastie 10 ปีที่แล้ว

    These videos are fantastic...im having a hard time with the if statement showing the fadeAmount = -fadeAmount ; I've watched the video several times but I'm not getting how the statement or the arduino knows to either add or subtract 5

    • @programmingelectronics
      @programmingelectronics  10 ปีที่แล้ว

      Daniel Clemente Great question. I like to picture a negative 1 in that line of code, like this:
      fadeAmount = -1 * fadeAmount;
      So if the brightness variable gets to 255, then fade amount gets multiplied by a "negative one". So if fadeAmount was "positive five", then:
      fadeAmount = -1 * 5;
      Since a negative number multiplied by a positive number results in a negative value, now fadeAmount becomes negative five. Now when brightness is equal to 0, it will look like this:
      fadeAmount = -1 * -5;
      Since two negative numbers multiplied together equal a positive, now fadeAmount, goes back to being a positive 5.
      The whole program, the sign keeps flipping back and forth like that.
      Hope this helps some. It can definitely be confusing!

    • @DanCoastie
      @DanCoastie 10 ปีที่แล้ว

      ok i think i get it...still a bit confusing...I think my problem is trying to understand how the program knows which to run...ahh ill figure it out lol

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

      Daniel Clemente Open Source Hardware Group If you get the math behind this it is superawsome. So: At the start of the code the brighness is 5. not 0 - because it gets added before we test the IF condition. at the first time it tests it is at 5 and then 10 and so on. When it reaches 255 (btw the fadeAmount HAVE to be devisable by 255 and it is with: 1,3,5,15,17,51 or 85) the condition is true and thus making the increment negative - because we stated that fadeAmount = -fadeAmount (keep this in mind that your fadeAmount is now Negative5). So the scripts jumps happily along and subtracts 5 until it reaches 0 and the condition is once again met. Now the fadeAmount (wich is at this point still negative 5) gets "negated" once again. Remember from math class - and - equals +? Well this is what is going on here. The negative number gets flipped back to fadeAmount (positive +). and the process repeats itself.
      I have added my extended challeng sketch cause I did not want the two LED's pulsing at the same rate: (NB notice that I have set the brightness2 to 250 - this is because of the same as above, that 250+5 = 255 so that it is at the peak from the very start) Sorry for the long wall of text but Im hooked on the tutorials here. SUPERAWSOME stuff!
      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
      int led2 = 11; // challenge test - multiple fading LED's
      int brightness2 = 250; // extended personal challenge
      int fadeAmount2 = 5; // think i need a double for this or - - - is - ;D
      // YaY I was right!!! the single fadeamount made wierd results
      // the setup routine runs once when you press reset:
      void setup() {
      // declare pin 9 to be an output:
      pinMode(led, OUTPUT);
      pinMode(led2, OUTPUT);
      }
      // the loop routine runs over and over again forever:
      void loop() {
      // set the brightness of pin 9:
      analogWrite(led, brightness);
      analogWrite(led2, brightness2); //extended personal challenge
      // change the brightness for next time through the loop:
      brightness = brightness + fadeAmount;
      brightness2 = brightness2 + fadeAmount2; //extended personal challenge
      // reverse the direction of the fading at the ends of the fade:
      if (brightness == 0 || brightness == 255) {
      fadeAmount = -fadeAmount ;
      }
      //extended personal challenge
      if (brightness2 == 0 || brightness2 == 255) {
      fadeAmount2 = -fadeAmount2 ;
      }
      // wait for 30 milliseconds to see the dimming effect
      delay(30);
      }
      Hope this helps more than it confuses you =) And if im wrong anywhere - please do point it out!

  • @warham1884
    @warham1884 7 ปีที่แล้ว

    Sir How Can I Fade LED Only Once
    And
    Why This Code Is Not Working
    int led = 9; // the PWM pin the LED is attached to
    int brightness = 225; // 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) {
    fadeAmount = 0 ;
    }
    // wait for 30 milliseconds to see the dimming effect
    delay(30);
    }

  • @thrices4372
    @thrices4372 9 ปีที่แล้ว +3

    i see that this example have:
    int led = 9; // the PWM pin the LED is attached to
    int brightness = 0; // how bright the LED is
    int fadeAmount = 5; // how many points to fade the LED by
    do this mean i can't use ping 0 and/or 5 as input or output?
    btw great tutorial!

    • @Terahspidgeon
      @Terahspidgeon 9 ปีที่แล้ว +4

      +pu yu No no no, you can still use pin 0 and 5. The 0 and 5 in this sample are values assigned to variables that are being used , not pin numbers.
      You could have
      int led = 5; //since 5 is also a PWM pin and this variable assigns a pin
      int brightness = 5; //this means the LED would start off glowing slightly instead of off since it will get 5
      volts for 5/255th of the time
      int fadeAmount = 5; //this is still the step size with which you control the LED brightness.

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

      Thrices to use a pin u have to declare the pin in setup using pinMode :)

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

    Great course!

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

    Thanks , the clarification I needed.

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

    really useful nd expecting more videos

  • @navjotsingh8372
    @navjotsingh8372 6 ปีที่แล้ว

    Excellent explanation