CODE | Pulsating Lamp - Arduino Project 007

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

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 | DTH Temperature & Humid Sensor - Arduino Project 036

CODE | DTH Temperature & Humid Sensor - Arduino Project 036

The DHT11 Temperature and Humidity Sensor senses, measures and regularly reports the relative humidi…

CODE | Line Following Robot - Arduino Project 030

CODE | Line Following Robot - Arduino Project 030

Project 30 Line Following RobotA line following robot is an autonomous vehicle that detects and foll…

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…

DIY T12 Soldering (Full-Assembled Kits)

DIY T12 Soldering (Full-Assembled Kits)

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

CODE | SD Card Information Basic - Arduino Project 042

CODE | SD Card Information Basic - Arduino Project 042

Arduino Programming Basic -- Reading and Writing to an SD CardSD cards have non-volatile flash memor…

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…

Post a Comment

Anonymous

Feel free to share your thoughts and opinions here.