<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://lms.onnocenter.or.id/wiki/index.php?action=history&amp;feed=atom&amp;title=Arduino%3A_Fade</id>
	<title>Arduino: Fade - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://lms.onnocenter.or.id/wiki/index.php?action=history&amp;feed=atom&amp;title=Arduino%3A_Fade"/>
	<link rel="alternate" type="text/html" href="https://lms.onnocenter.or.id/wiki/index.php?title=Arduino:_Fade&amp;action=history"/>
	<updated>2026-04-20T15:47:55Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://lms.onnocenter.or.id/wiki/index.php?title=Arduino:_Fade&amp;diff=45223&amp;oldid=prev</id>
		<title>Onnowpurbo: New page: This example demonstrates the use of the analogWrite() function in fading an LED off and on. AnalogWrite uses pulse width modulation (PWM), turning a digital pin on and off very quickly wi...</title>
		<link rel="alternate" type="text/html" href="https://lms.onnocenter.or.id/wiki/index.php?title=Arduino:_Fade&amp;diff=45223&amp;oldid=prev"/>
		<updated>2015-12-04T02:43:03Z</updated>

		<summary type="html">&lt;p&gt;New page: This example demonstrates the use of the analogWrite() function in fading an LED off and on. AnalogWrite uses pulse width modulation (PWM), turning a digital pin on and off very quickly wi...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This example demonstrates the use of the analogWrite() function in fading an LED off and on. AnalogWrite uses pulse width modulation (PWM), turning a digital pin on and off very quickly with different ratio between on and off, to create a fading effect.&lt;br /&gt;
&lt;br /&gt;
==Hardware Required==&lt;br /&gt;
&lt;br /&gt;
* Arduino or Genuino board&lt;br /&gt;
* LED&lt;br /&gt;
* 220 ohm resistor&lt;br /&gt;
* hook-up wires&lt;br /&gt;
* breadboard &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Rangakaian==&lt;br /&gt;
&lt;br /&gt;
[[Image:Simplefade bb.png|center|200px|thumb]]&lt;br /&gt;
&lt;br /&gt;
[[Image:Simplefade pin9 schem.png|center|200px|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&lt;br /&gt;
 /*&lt;br /&gt;
  Fade&lt;br /&gt;
 &lt;br /&gt;
  This example shows how to fade an LED on pin 9&lt;br /&gt;
  using the analogWrite() function.&lt;br /&gt;
 &lt;br /&gt;
  The analogWrite() function uses PWM, so if&lt;br /&gt;
  you want to change the pin you&amp;#039;re using, be&lt;br /&gt;
  sure to use another PWM capable pin. On most&lt;br /&gt;
  Arduino, the PWM pins are identified with&lt;br /&gt;
  a &amp;quot;~&amp;quot; sign, like ~3, ~5, ~6, ~9, ~10 and ~11.&lt;br /&gt;
 &lt;br /&gt;
  This example code is in the public domain.&lt;br /&gt;
  */&lt;br /&gt;
 &lt;br /&gt;
 int led = 9;           // the PWM pin the LED is attached to&lt;br /&gt;
 int brightness = 0;    // how bright the LED is&lt;br /&gt;
 int fadeAmount = 5;    // how many points to fade the LED by&lt;br /&gt;
 &lt;br /&gt;
 // the setup routine runs once when you press reset:&lt;br /&gt;
 void setup() {&lt;br /&gt;
   // declare pin 9 to be an output:&lt;br /&gt;
   pinMode(led, OUTPUT);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 // the loop routine runs over and over again forever:&lt;br /&gt;
 void loop() {&lt;br /&gt;
   // set the brightness of pin 9:&lt;br /&gt;
   analogWrite(led, brightness);&lt;br /&gt;
 &lt;br /&gt;
   // change the brightness for next time through the loop:&lt;br /&gt;
   brightness = brightness + fadeAmount;&lt;br /&gt;
 &lt;br /&gt;
   // reverse the direction of the fading at the ends of the fade:&lt;br /&gt;
   if (brightness == 0 || brightness == 255) {&lt;br /&gt;
     fadeAmount = -fadeAmount ;&lt;br /&gt;
   }&lt;br /&gt;
   // wait for 30 milliseconds to see the dimming effect&lt;br /&gt;
   delay(30);&lt;br /&gt;
 }&lt;/div&gt;</summary>
		<author><name>Onnowpurbo</name></author>
	</entry>
</feed>