CODE | Pulsating Lamp - Arduino Project 007

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

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 | Ultrasonic Distance OLED 128x64 Display - Arduino Project 041

CODE | Ultrasonic Distance OLED 128x64 Display - Arduino Project 041

About the Ultrasonic sensor knowledge and infor mation click the link : Arduino Project 038 - S…

CODE | Shift Register 8-Bit Binary Counter - Arduino Project 017

CODE | Shift Register 8-Bit Binary Counter - Arduino Project 017

In this project, you’re going to use additional ICs (Integrated Circuits) in the form of shift regis…

CODE | Variables - Arduino Programming Basic

CODE | Variables - Arduino Programming Basic

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

CODE | L293D Motor Driver IC - Arduino Project 016

CODE | L293D Motor Driver IC - Arduino Project 016

In the previous project, you used a transistor to control the motor. In this project, you are going…

How to Selection Soldering for your Maker

How to Selection Soldering for your Maker

如何选用合适的电络铁?初级电子制作与维修之工具选择电烙铁是我们电子制作和装配中,导线、延长线连接,电子元件的安装和拆卸的必备工具。尤其是在电器维修中也是最常用的工具。电烙铁的分类电络铁的分类方式很多,…

CODE | LED Chase Lights - Arduino Project 005

CODE | LED Chase Lights - Arduino Project 005

You’re going to use a string of LEDs (10 in total) to make an LED chase effect, similar to that used…

Post a Comment

Anonymous

Feel free to share your thoughts and opinions here.