CODE | Pulsating Lamp - Arduino Project 007

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

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

Setting Up an LNMP Environment on CentOS 7.9 64-bit

Setting Up an LNMP Environment on CentOS 7.9 64-bit

CentOS 7.9 64位 搭建 LNMP环境What is a LAMPLAMP is a free and open source software suite combines four po…

CODE | LED Fire Effect - Arduino Project 009

CODE | LED Fire Effect - Arduino Project 009

Project 9 will use LEDs and a flickering random light effect, via PWM again, to mimic the effect of…

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…

STEM|60个好玩的 APP推荐

STEM|60个好玩的 APP推荐

STEAM教育理念最早是美国政府提出的教育倡议,为加强美国K12(中小学)关于科学、技术、工程、艺术以及数学的教育。STEAM的原身是STEM理念,即科学(Science)、技术(Technology…

Resistor-Electrical Components

Resistor-Electrical Components

A resistor is a passive two-terminal electrical component that implements electrical resistance as a…

Identifying Color-Band Resistors and Reading Their Values

Identifying Color-Band Resistors and Reading Their Values

色环电阻的识别与数值读取色环电阻是在电阻封装上(即电阻表面)涂上一定颜色的色环,来代表这个电阻的阻值。色环实际上是早期为了帮助人们分辨不同阻值而设定的标准。色环电阻应用还是很广泛的,如家用电器、电子仪…

Post a Comment

Anonymous

Feel free to share your thoughts and opinions here.