CODE | Pulsating Lamp - Arduino Project 007

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

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 | LED Interactive Traffic Lights - Arduino Project 004

CODE | LED Interactive Traffic Lights - Arduino Project 004

This time you are going to extend the previous project to include a set of pedestrian lights and a p…

How to Choose the Right Wire Stripper Tool?

How to Choose the Right Wire Stripper Tool?

剥线钳是弱电工程师、内线电工、电动机修理、仪器仪表电工及电子制作爱好者常用的工具之一,用来供操作者剥除电线头部的表面绝缘层。剥线钳可以使得电线被切断的绝缘皮与电线分开,可以在不损坏内部金属线层的情况下…

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 | LCD Temperature Display - Arduino Project 024

CODE | LCD Temperature Display - Arduino Project 024

This project is a simple demonstration of using an LCD to present useful information to the user—in…

CODE | Control Stepper Motor ULN2004A - Arduino Project 029

CODE | Control Stepper Motor ULN2004A - Arduino Project 029

Stepper motors, due to their unique design, can be controlled to a high degree of accuracy without a…

Series and parallel circuits

Series and parallel circuits

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.