CODE | Pulsating Lamp - Arduino Project 007

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

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 | 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…

DIY T12 Soldering (Full-Assembled Kits)

DIY T12 Soldering (Full-Assembled Kits)

前两天我们刚做了一起T12焊台的半散件的DIY组装,但是很多小伙伴反应这个版本的不够过瘾,对T12焊台的结构还是一知半解的,所以今天我们在上一期的基础上做一期特别的,全散件T12零件包的DIY组装视频…

Centos Install OSCommerce 4.0

Centos Install OSCommerce 4.0

osCommerce is a Free shopping cart and open source Ecommerce software. You can choose to host your o…

How to Choose the Right Wire Stripper Tool?

How to Choose the Right Wire Stripper Tool?

剥线钳是弱电工程师、内线电工、电动机修理、仪器仪表电工及电子制作爱好者常用的工具之一,用来供操作者剥除电线头部的表面绝缘层。剥线钳可以使得电线被切断的绝缘皮与电线分开,可以在不损坏内部金属线层的情况下…

CODE |  Liquid Crystal Displays-Blink and Cursor - Arduino Project 023B

CODE | Liquid Crystal Displays-Blink and Cursor - Arduino Project 023B

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

Python Programming Languages Suitable for Children

Python Programming Languages Suitable for Children

Python 适合儿童的编程语言Scratch图形编程优点在于图形化拖拽的方式简化了编程的理解,而C,JAVA,JAVASCRIPT,PYTHON等编程语言相对枯燥复杂,涉及复杂编程语法,变量规则,函…

Post a Comment

Anonymous

Feel free to share your thoughts and opinions here.