CODE | Pulsating Lamp - Arduino Project 007

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

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 | BMP280 Pressure Sensor LCD Display - Arduino Project 032

CODE | BMP280 Pressure Sensor LCD Display - Arduino Project 032

For this project we will use Arduino Uno and BMP280 along with LCD 16x2 display module to display te…

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 | Dual Servo Control - Arduino Project 026

CODE | Dual Servo Control - Arduino Project 026

This project you’ll create another simple project, but this time you’ll control two servos using com…

CODE | Basic Stepper Control (Bipolar) - Serial to Display - Arduino Project 028A

CODE | Basic Stepper Control (Bipolar) - Serial to Display - Arduino Project 028A

In this very simple project, you will connect up a stepper motor and then get the Arduino to control…

Arduino Retired Products & Legacy Doc

Arduino Retired Products & Legacy Doc

Arduino Retired Products & Legacy Documentation fromArduino website. Update time : Jan.1.2023&nb…

CODE | Data Type - Arduino Programming Basic

CODE | Data Type - Arduino Programming Basic

Arduino 程序基础,介绍Arduino程序的基本组成,第一部分编写了10个例子,关于变量及变量名称,串口监视器,if循环,for循环,while循环等。第二部分介绍了函数,全局变量,局部变量和静…

Post a Comment

Anonymous

Feel free to share your thoughts and opinions here.