This is simple demonstration of arduino's builtin fade LED example code but using 12v bulb and mosfet instead of LED and driving the bulb through n-channel mosfet and mosfet is driven by optocoupler iaolation. purpose of this example is to safely operate any hight voltage load using arduino through galvanic isolation of optocoupler thus avoiding any damage to arduino
this example used PWM example to fade the light bulb by changing the duty cycle of signal at pin 3. speed of DC motor can also be controlled using this example
Dive into the world of DIY electronics as we present a simple yet fascinating demonstration using Arduino's built-in Fade LED example code. In this project, we take it up a notch by swapping the LED for a dynamic 12V bulb and harnessing the power of a MOSFET. Watch as the bulb fades gracefully, creating a visually stunning effect.
Arduino Light bulb fading using MOSFET and Optocoupler
But that's not all! The key purpose of this example is to showcase the safe operation of high-voltage loads with Arduino.
Through the galvanic isolation of an optocoupler, potential damage to your Arduino is effectively avoided. Safety meets innovation in this enlightening project.
Unlock the potential of your Arduino with PWM control! Learn how to manipulate the light bulb's intensity by adjusting the duty cycle at pin 3. And here's the exciting part – the same example empowers you to control the speed of a DC motor. It's a versatile journey into the realm of creative coding!
Ready to embark on this electrifying adventure? Copy the code bellow, upload it to your Arduino, and witness the magic unfold. Don't miss out on more captivating projects – visit our Youtube channell HobbyElectroLab and discover a treasure trove of DIY electronics.
int led = 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(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(20);
}
In this project will get the answers fo the following question.
Arduino programming for beginners.
arduino fade led tutorial.
How to Fade a Bulb with Arduino analogWrite function.
LED Fading Arduino code .
Arduino Tutorial.
Understanding the Arduino Analog Write Command.
How to Use analogWrite Command in Arduino