CODE | Pulsating Lamp - Arduino Project 007

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

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 | TM1637 4Digital 7Segment Display Module - Arduino Project 034

CODE | TM1637 4Digital 7Segment Display Module - Arduino Project 034

A standard 4-digit 7-segment display is needed for clock, timer and counter projects, but it usually…

CODE | Dual Servo Control - Arduino Project 026

CODE | Dual Servo Control - Arduino Project 026

This project you’ll create another simple project, but this time you’ll control two servos using com…

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 | LED Dot Matrix Display Pong Game - Arduino Project 022

CODE | LED Dot Matrix Display Pong Game - Arduino Project 022

This project was hard going and a lot to take in. So, for Project 22 you are going to create a simpl…

CODE | Piezo Sounder Melody Player - Arduino Project 012

CODE | Piezo Sounder Melody Player - Arduino Project 012

Rather than using the piezo to make annoying alarm sounds, why not use it to play a melody? You are…

CODE | Serial Controlled Mood Lamp - Arduino Project 010

CODE | Serial Controlled Mood Lamp - Arduino Project 010

For Project 10, you will revisit the circuit from Project 8 — RGB Mood Lamp, but you’ll now delve in…

Post a Comment

Anonymous

Feel free to share your thoughts and opinions here.