Theory (PWM) | Arduino Lesson 3. RGB LEDs

Skip to main content Arduino Lesson 3. RGB LEDs Theory (PWM)
  • Overview
  • Parts
  • Breadboard Layout
  • Colors
  • Arduino Sketch
  • Using Internet Colors
  • Theory (PWM)
  • Other Things to Do
  • Single page
  • Feedback? Corrections?
  • Text View
Groups
  • Learn Arduino
Featured Products view all
  • Angled shot of a Adafruit METRO 328 Fully Assembled Adafruit METRO 328 Fully Assembled - Arduino IDE compatible Out of Stock
  • Angled shot of Premium Male/Male Jumper Wires - 40 x 6 (150mm) Premium Male/Male Jumper Wires - 40 x 6" (150mm) Out of Stock
  • Angled shot of half-size solderless breadboard with red and black power lines. Half Sized Premium Breadboard - 400 Tie Points $4.95 Add to Cart
  • Single diffused LED with four legs, Diffused RGB (tri-color) LED $2.00 Add to Cart
121 Beginner Skill guide 💕 1

Theory (PWM)

Pulse Width Modulation (or PWM) is a technique for controlling power.  We also use it here to control the brightness of each of the LEDs. The diagram below shows the signal from one of the PWM pins on the Arduino. learn_arduino_how_pwm_works.jpg Roughly every 1/500 of a second, the PWM output will produce a pulse. The length of this pulse is controlled by the 'analogWrite' function. So 'analogWrite(0)' will not produce any pulse at all and 'analogWrite(255)' will produce a pulse that lasts all the way until the next pulse is due, so that the output is actually on all the time.If we specify a value in the analogWrite that is somewhere in between 0 and 255 then we will produce a pulse. If the output pulse is only high for 5% of the time then whatever we are driving will only receive 5% of full power. If however the output is at 5V for 90% of the time then the load will get 90% of the power delivered to it. We cannot see the LEDs turning on and off at that speed, so to us, it just looks like the brightness is changing. 

Page last edited October 02, 2012

Text editor powered by tinymce.

Using Internet Colors Other Things to Do Related Guides WiFi Candy Bowl Monitor By Tony DiCola beginner Programming Arduino with Android and Windows Tablets By Anne Barela beginner Mini Thermal Receipt Printers By Phillip Burgess beginner Making Adabot: Part 2 By Rick Winscot beginner Your browser does not support the video tag. This links to the guide Using NeoPixels and Servos Together. Using NeoPixels and Servos Together By Phillip Burgess intermediate Adafruit Data Logger Shield By Bill Earl beginner Introducing Adafruit Trellis By lady ada beginner Arduino "Hunt The Wumpus" By Dan Malec beginner Sending an SMS with Temboo By Vaughn Shinall advanced Adafruit Ultimate GPS Logger Shield By lady ada intermediate A REST API for Arduino & the CC3000 WiFi Chip By M. Schwartz beginner Program an AVR or Arduino Using Raspberry Pi GPIO By Tony DiCola intermediate Arduino Lesson 12. LCD Displays - Part 2 By Simon Monk beginner Adafruit Motor Shield By lady ada intermediate NeoPixel Painter By Phillip Burgess beginner
Create Wishlist
× Title Description Close Search Search
Categories

Tag » Arduino Pwm Led Rgb