CODE | Pulsating Lamp - Arduino Project 007

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

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 | 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 | LCD Temperature Display - Arduino Project 024

CODE | LCD Temperature Display - Arduino Project 024

This project is a simple demonstration of using an LCD to present useful information to the user—in…

CODE | Ultrasonic Distance Display - Arduino Project 039

CODE | Ultrasonic Distance Display - Arduino Project 039

Ultrasonic sensors measure distance by sending and receiving the ultrasonic wave. The ultrasonic sen…

CODE | Keypad 4X4 or 4X3 - Arduino Project 035

CODE | Keypad 4X4 or 4X3 - Arduino Project 035

Most of the time we are used key, button, or switch to get input value in our projects. When we inte…

Electric and Sensor Control System

Electric and Sensor Control System

Since 2022, the founder of Autaba EC deparrment has devoted to the research and development of advan…

Installing Redis on CentOS and Configuring Redis

Installing Redis on CentOS and Configuring Redis

CentOS安装Redis及redis启动与关闭、配置Install RedisIn this section you’ll add theEPEL repository, and then…

Post a Comment

Anonymous

Feel free to share your thoughts and opinions here.