CODE | Pulsating Lamp - Arduino Project 007

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

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 | 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…

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…

CODE | Human Body Infrared Detector and Relay Light - Arduino Project 048

CODE | Human Body Infrared Detector and Relay Light - Arduino Project 048

Project 48 Human Body Infrared Detector and Relay LightThis Infrared Human Sensor referenc…

CODE | SD Card Temperature Datalogger - Arduino Project 043

CODE | SD Card Temperature Datalogger - Arduino Project 043

Todady I made a simple Arduino datalogger using SD card and DHT11  relative humidity and t…

CODE | Simple Motor Control - Arduino Project 015

CODE | Simple Motor Control - Arduino Project 015

First, you’re going to simply control the speed of a DC motor in one direction, using a power transi…

Series and Parallel resistors

Series and Parallel resistors

Two-terminal components and electrical networks can be connected in series or parallel. The resultin…

Post a Comment

Anonymous

Feel free to share your thoughts and opinions here.