CODE | Pulsating Lamp - Arduino Project 007

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

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

Arduino software Download

Arduino software Download

Arduino Web EditorStart coding online and save your sketches in the cloud. The most up-to-date versi…

Electric Maker Beginner Tools Kit

Electric Maker Beginner Tools Kit

This assortment of tools has everything you need to get started tinkering with Sparkfun products and…

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…

C04 | Compilation and Execution of Programs

C04 | Compilation and Execution of Programs

C语言教程04:程序的编译与运行源程序也称源代码,是指未编译的、按照一定的程序设计语言规范书写的文本文件,是一系列人类可读的计算机语言指令,可以用汇编语言或高级语言编写。计算机源代码的最终目的是将人类…

Setting Up the Environment for Aliun Server

Setting Up the Environment for Aliun Server

阿里云服务器的环境搭建与调试从阿里云产品发布开始便一直在使用ECM云服务器,但是之前多使用的是Windows系统,后来摸索开始挑战自己使用CentOS系统,靠着几行程序和网上各位大咖的教程和分享,竟然…

Post a Comment

Anonymous

Feel free to share your thoughts and opinions here.