CODE | Pulsating Lamp - Arduino Project 007

RonWang3 years ago (2023-06-29)电子编程 COD18

You are now going try a more advanced method of controlling LEDs. So far, you have simply turned the LED on or off. Would you like to adjust the brightness of an LED? Can you do that with an Arduino? Yes, you can. Time to go back to basics.

项目7 调节LED灯的亮度Project 7 - Pulsating lamp

001 LED Blink Circuit

/* Coding Ron Wang
   July 2nd 2024
   Autaba support for coding hardware
 */
// Project 7 - Pulsating lamp
int ledPin = 10;
float sinVal;
int ledVal;
void setup() {
 pinMode(ledPin, OUTPUT);
}
void loop() {
 for (int x=0; x<180; x++) {
 // convert degrees to radians then obtain sin value
 sinVal = (sin(x*(3.1412/180)));
 ledVal = int(sinVal*255);
 analogWrite(ledPin, ledVal);
 delay(25);
 }
}

           

Share with Friends:

Related Articles

CODE | LED Dot Matrix Display Basic Animation - Arduino Project 019

CODE | LED Dot Matrix Display Basic Animation - Arduino Project 019

So far you have dealt with individual 5mm LEDs. LEDs can also be obtained in a package known as a do…

CODE | Light Sensor - Arduino Project 014

CODE | Light Sensor - Arduino Project 014

This project introduces a new component known as a Light Dependent Resistor, or LDR. As the name imp…

About Arduino Resources

About Arduino Resources

The Arduino platform benefits from an active user community that makes it easy to get help from fell…

CODE | Ultrasonic Distance Display - Arduino Project 039

CODE | Ultrasonic Distance Display - Arduino Project 039

Ultrasonic sensors measure distance by sending and receiving the ultrasonic wave. The ultrasonic sen…

CODE | Liquid Crystal Displays-Serial to Display - Arduino Project 023C

CODE | Liquid Crystal Displays-Serial to Display - Arduino Project 023C

Before wiring the LCD screen to your Arduino board we suggest to solder a pin header strip to the 14…

CODE | LED Dot Matrix Display Beat Heart - Arduino Project 020

CODE | LED Dot Matrix Display Beat Heart - Arduino Project 020

You’re going to use the same circuit, but with a slight variation in the code to create a multi-fram…

Post a Comment

Anonymous

Feel free to share your thoughts and opinions here.