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

preview_player
Показать описание


0:00 intro
0:17 circuit overview
0:40 pulse width modulation (PWM) pins
2:16 open an example program
3:12 for loops
6:36 run the example program
7:06 change the fade speed
7:55 how does PWM work?
10:55 up next

#STEM #sciencebuddies #arduino #electronics #programming
*******************************
Connect with Science Buddies:

Рекомендации по теме
Комментарии
Автор

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!.

RohanRauf-uqky
Автор

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.

lukemanning
Автор

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

SnakePicks
Автор

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

ingenierocivilizado
Автор

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

SilentEmilie
Автор

These are all so awesome to learn! Thanks!

StoicOptim
Автор

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

manu
Автор

Thank you so much for the video! So easy to understand. Also, can I ask if this type of function works for solenoid valves that gradually close as time runs out? Thank you so much!!

imsaikoo
Автор

Great videos! How do I learn what size resistors and etc I'll need?

skylinegt
Автор

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

castelmichel
Автор

Thankyou!! But does this work with 6 led?

angela.
Автор

just a question i have a arduino mega and non of them have the pwm is the arduino mega different or does it not work on the mega?

hossambarakat
Автор

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

cadillacescalade
Автор

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?

helenavont
Автор

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?

ProsperTeni
Автор

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

YouDontKnowMetx
Автор

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

wynixcabantac