CODE | Pulsating Lamp - Arduino Project 007

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

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 Chase Effect - Arduino Project 006

CODE | LED Interactive Chase Effect - Arduino Project 006

Leave your circuit board intact from Project 5. You’re just going to add a potentiometer to this cir…

Series and parallel circuits

Series and parallel circuits

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

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…

The incredible growth of Python

The incredible growth of Python

Python is a powerful programming language and Big Scope of Python   Programming Language. Pytho…

Centos Install MemCached, Apcu and OpCache

Centos Install MemCached, Apcu and OpCache

This section provides instructions to install memcached on CentOS and Ubuntu. For additional informa…

CODE | Piezo Knock Sensor - Arduino Project 013

CODE | Piezo Knock Sensor - Arduino Project 013

A piezo disc works when an electric current is passed over the ceramic material in the disc, causing…

Post a Comment

Anonymous

Feel free to share your thoughts and opinions here.