CODE | Pulsating Lamp - Arduino Project 007

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

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

Mounting a Hard Drive on a CentOS Server

Mounting a Hard Drive on a CentOS Server

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

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…

CODE | How to Connect Remote Control - Arduino Project 047

CODE | How to Connect Remote Control - Arduino Project 047

In the first time I purchase this remote, I don't know why the operating mode is only non-latche…

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…

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…

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.