CODE | Pulsating Lamp - Arduino Project 007

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

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

Identifying Color-Band Resistors and Reading Their Values

Identifying Color-Band Resistors and Reading Their Values

色环电阻的识别与数值读取色环电阻是在电阻封装上(即电阻表面)涂上一定颜色的色环,来代表这个电阻的阻值。色环实际上是早期为了帮助人们分辨不同阻值而设定的标准。色环电阻应用还是很广泛的,如家用电器、电子仪…

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…

How to use the Soldering Electric Maker Basic Technology

How to use the Soldering Electric Maker Basic Technology

如何使用电络铁?初级电子制作与维修之焊接知识Gather Tools: You will need a soldering iron, solder, a soldering iron stand,…

DIY T12 Soldering (Partial -Assembled Kits)

DIY T12 Soldering (Partial -Assembled Kits)

今天我们要自己动手做一台高性价比的T12焊台,我们通过DIY来体验T12的快速温升带给我们焊接的畅快。T12的焊台有什么让人着迷地方?为什么很多焊接达人,都希望拥有一台高品质的T12焊台,DIY一台T…

CODE | LED Fire Effect - Arduino Project 009

CODE | LED Fire Effect - Arduino Project 009

Project 9 will use LEDs and a flickering random light effect, via PWM again, to mimic the effect of…

CODE | Dual Motor Driver L298N - Arduino Project 030A

CODE | Dual Motor Driver L298N - Arduino Project 030A

L298N Dual Motor Driver Project Description The L298N Motor Driver is a controller that uses an…

Post a Comment

Anonymous

Feel free to share your thoughts and opinions here.