CODE | Pulsating Lamp - Arduino Project 007

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

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

C02 | The Concept of Algorithms

C02 | The Concept of Algorithms

C语言教程02:算法的概念算法(Algorithm)是在有限步骤内求解某一问题所使用的一组定义明确的规则。计算机算法 是用计算机求解一个具体问题或执行特定任务的一组有序的操作步骤(或指令),是构成计算…

CODE | Digital Pressure Sensor - Arduino Project 031

CODE | Digital Pressure Sensor - Arduino Project 031

Arduino Programming Basic -- Pressure SensorsPressure sensors are integral components in a multitude…

CODE | Joystick Servo Control - Arduino Project 027

CODE | Joystick Servo Control - Arduino Project 027

In this tutorial, we are going to learn how to use Arduino and a joystick to control two servo motor…

CODE | Simple RFID Reader - Arduino Project 044

CODE | Simple RFID Reader - Arduino Project 044

Arduino Programming Basic -- Making an RFID ReaderAdvanced RFID with ArduinoRFID (Radio Frequency Id…

CODE | RFID Servo and LED Control System - Arduino Project 045

CODE | RFID Servo and LED Control System - Arduino Project 045

Arduino Programming Basic -- RFID Servo and LED Control System Integrating RFID technology…

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…

Post a Comment

Anonymous

Feel free to share your thoughts and opinions here.