CODE | Pulsating Lamp - Arduino Project 007

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

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 | Liquid Crystal Displays-Serial to Display - Arduino Project 023C

CODE | Liquid Crystal Displays-Serial to Display - Arduino Project 023C

Before wiring the LCD screen to your Arduino board we suggest to solder a pin header strip to the 14…

CODE | Ultrasonic Distance OLED 128x64 Display - Arduino Project 041

CODE | Ultrasonic Distance OLED 128x64 Display - Arduino Project 041

About the Ultrasonic sensor knowledge and infor mation click the link : Arduino Project 038 - S…

CODE | LED Traffic Light - Arduino Project 003

CODE | LED Traffic Light - Arduino Project 003

You are now going to create a set of traffic lights that will change from green to red, via amber, a…

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 | Serial Controlled Mood Lamp - Arduino Project 010

CODE | Serial Controlled Mood Lamp - Arduino Project 010

For Project 10, you will revisit the circuit from Project 8 — RGB Mood Lamp, but you’ll now delve in…

Coding | 锻炼孩子的逻辑思维

Coding | 锻炼孩子的逻辑思维

自然语言(人类的语言)和计算机语言之间有许多相似之处,学习计算机语言类似于学习一门外语语法。 计算机编程或者算法的难点和意义是,是编程思维和解决问题能力。程序设计早已不是程序员们独有的技术活了,很多国…

Post a Comment

Anonymous

Feel free to share your thoughts and opinions here.