Fading using an Arduino




Demonstrates the use of analog output (Pulse Width Modulation (PWM)) to fade an LED. PWM is a technique for getting an analog-like behavior from a digital output by switching it off and on very fast.

Fading using an Arduino




Circuit

An LED connected to digital output pin 9 through a 220-ohm resistor.

Schematic

image developed using Fritzing. For more circuit examples, see the Fritzing project page

Fading using an Arduino schematic

Code

/*
Fading

This example shows how to fade an LED using the analogWrite() function.
The circuit:
* LED attached from digital pin 9 to ground.
Created 1 Nov 2008
By David A. Mellis
modified 30 Aug 2011
By Tom Igoe
http://arduino.cc/en/Tutorial/Fading
This example code is in the public domain.

*/
int ledPin = 9;    // LED connected to digital pin 9
void setup()  {
// nothing happens in setup
}

 

Major Components in Project

Arduino

For more detail: Fading using an Arduino




This Post / Project can also be found using search terms:

  • project arduino fading
Clip to Evernote

Leave a Comment

(Spamcheck Enabled)

Read previous post:
Build Temperature & Humidity & Smoke Detector Alarm System Based on Arduino

Project Summary: Build temperature & humidity & smoke alarm system based on ICStation Mega 2560 compatible with Arduino( Cost is...

Close
Scroll to top