CODE | Pulsating Lamp - Arduino Project 007

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

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 | Shift Register 8-Bit Binary Counter - Arduino Project 017

CODE | Shift Register 8-Bit Binary Counter - Arduino Project 017

In this project, you’re going to use additional ICs (Integrated Circuits) in the form of shift regis…

DIY T12 Soldering (Partial -Assembled Kits)

DIY T12 Soldering (Partial -Assembled Kits)

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

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…

 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 | Simple RFID Reader - Arduino Project 044

CODE | Simple RFID Reader - Arduino Project 044

Arduino Programming Basic -- Making an RFID ReaderAdvanced RFID with ArduinoRFID (Radio Frequency Id…

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…

Post a Comment

Anonymous

Feel free to share your thoughts and opinions here.