CODE | Pulsating Lamp - Arduino Project 007

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

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 |  Liquid Crystal Displays-Blink and Cursor - Arduino Project 023B

CODE | Liquid Crystal Displays-Blink and Cursor - Arduino Project 023B

Before wiring the LCD screen to your Arduino board we suggest to solder a pin header strip to the 14…

Identifying Color-Band Resistors and Reading Their Values

Identifying Color-Band Resistors and Reading Their Values

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

 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 | How to Connect Remote Control - Arduino Project 047

CODE | How to Connect Remote Control - Arduino Project 047

In the first time I purchase this remote, I don't know why the operating mode is only non-latche…

C01 | The Past and Present of the C Language

C01 | The Past and Present of the C Language

C语言教程01:C语言的前世今生程序设计语言的发展经历了从机器语言->汇编语言->高级语言的过程机器语言:是计算机最原始的语言,由 0 和 1 的代码构成,CPU 在工作的时候只认识机 器…

CODE | Dual Shift Register 8-Bit Binary Counter - Arduino Project 018

CODE | Dual Shift Register 8-Bit Binary Counter - Arduino Project 018

In Project 18, you will daisy chain (or cascade) another 74HC595 IC onto the one used in Project 17…

Post a Comment

Anonymous

Feel free to share your thoughts and opinions here.