CODE | Pulsating Lamp - Arduino Project 007

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

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 | 4 Digital 7 Segment Display - Arduino Project 033

CODE | 4 Digital 7 Segment Display - Arduino Project 033

Showing Heep and number 0-9 on a Common Anode 7-segment LED display. Displays the numbers 0-9 on the…

CentOS Server PHP 7.4+ Installation

CentOS Server PHP 7.4+ Installation

Centos服务器PHP7.4+安装IntroductionA LEMP software stack is a group of open source software that is typic…

CODE | Simple Ultrasonic Range HC-SR04 - Arduino Project 038

CODE | Simple Ultrasonic Range HC-SR04 - Arduino Project 038

Ultrasonic range finders measure distance by emitting a pulse of ultrasonic sound that travels throu…

About Arduino Resources

About Arduino Resources

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

Electric and Sensor Control System

Electric and Sensor Control System

Since 2022, the founder of Autaba EC deparrment has devoted to the research and development of advan…

CODE | Human Body Infrared Detector and Relay Light - Arduino Project 048

CODE | Human Body Infrared Detector and Relay Light - Arduino Project 048

Project 48 Human Body Infrared Detector and Relay LightThis Infrared Human Sensor referenc…

Post a Comment

Anonymous

Feel free to share your thoughts and opinions here.