CODE | Pulsating Lamp - Arduino Project 007

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

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

DIY T12 Soldering (Full-Assembled Kits)

DIY T12 Soldering (Full-Assembled Kits)

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

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,设置呗,好像我…

Electronic color code

Electronic color code

An electronic color code or is used to indicate the values or ratings of electronic components, usua…

Mounting a Hard Drive on a CentOS Server

Mounting a Hard Drive on a CentOS Server

Centos服务器挂载硬盘1. 查看服务器上未挂载的磁盘(磁盘有普通磁盘,高效磁盘,SSD磁盘Bashfdisk -l…

CODE | Simple Ultrasonic Range HC-SR04 - Arduino Project 038

CODE | Simple Ultrasonic Range HC-SR04 - Arduino Project 038

Ultrasonic range finders measure distance by emitting a pulse of ultrasonic sound that travels throu…

CODE | LED Dot Matrix Display Basic Animation - Arduino Project 019

CODE | LED Dot Matrix Display Basic Animation - Arduino Project 019

So far you have dealt with individual 5mm LEDs. LEDs can also be obtained in a package known as a do…

Post a Comment

Anonymous

Feel free to share your thoughts and opinions here.