CODE | Pulsating Lamp - Arduino Project 007

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

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 | Piezo Sounder Alarm - Arduino Project 011

CODE | Piezo Sounder Alarm - Arduino Project 011

Arduino project - sounder and sensors : Include project 11 Piezo Sounder Alarm ,Project piezo sounde…

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…

CODE | Liquid Crystal Displays-Serial to Display - Arduino Project 037

CODE | Liquid Crystal Displays-Serial to Display - Arduino Project 037

The DS18B20 Temperature Sensor is a digital temperature sensor capable of measuring temperatures wit…

CODE | Dot Matrix Display Beat Heart - Valentine's Day Gift

CODE | Dot Matrix Display Beat Heart - Valentine's Day Gift

You’re going to use the Project 19 circuit, but with a slight variation in the code to create a mult…

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 | RFID Servo and LED Control System - Arduino Project 045

CODE | RFID Servo and LED Control System - Arduino Project 045

Arduino Programming Basic -- RFID Servo and LED Control System Integrating RFID technology…

Post a Comment

Anonymous

Feel free to share your thoughts and opinions here.