CODE | Pulsating Lamp - Arduino Project 007

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

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 | RGB LED Mood Lamp - Arduino Project 008

CODE | RGB LED Mood Lamp - Arduino Project 008

In the last project, you learned how to adjust the brightness of an LED using the PWM capabilities o…

CODE | Digital Pressure Sensor - Arduino Project 031

CODE | Digital Pressure Sensor - Arduino Project 031

Arduino Programming Basic -- Pressure SensorsPressure sensors are integral components in a multitude…

Resolving the Need to Enter FTP Credentials for WordPress Themes and Plugins

Resolving the Need to Enter FTP Credentials for WordPress Themes and Plugins

解决安装WordPress主题及插件需要输入FTP问题安装一个WordPress好像挺简单,但是默认主题不喜欢,想更换一个,无奈本地可以更换,但是服务器更换的时候需要设置FTP 。OK,设置呗,好像我…

CODE | LED Dot Matrix Display Scrolling Message - Arduino Project 021

CODE | LED Dot Matrix Display Scrolling Message - Arduino Project 021

There are many different ways to drive LEDs. Using shift registers is one way and they have their a…

CODE | Dual Motor Driver L298N - Arduino Project 030A

CODE | Dual Motor Driver L298N - Arduino Project 030A

L298N Dual Motor Driver Project Description The L298N Motor Driver is a controller that uses an…

CODE | Variables - Arduino Programming Basic

CODE | Variables - Arduino Programming Basic

Arduino 程序基础,介绍Arduino程序的基本组成,第一部分编写了10个例子,关于变量及变量名称,串口监视器,if循环,for循环,while循环等。第二部分介绍了函数,全局变量,局部变量和静…

Post a Comment

Anonymous

Feel free to share your thoughts and opinions here.