Tutorial.AnalogWriteMega History

Show minor edits - Show changes to markup

October 29, 2015, at 03:45 PM by Gabriele Marchi -
Changed lines 33-34 from:
to:
October 29, 2015, at 03:42 PM by Gabriele Marchi -
Changed lines 33-34 from:
to:
August 27, 2015, at 03:15 PM by Simone Maiocchi -
Changed lines 1-6 from:
to:
August 27, 2015, at 03:10 PM by Simone Maiocchi -
Added line 11:

Hardware Required

Changed line 13 from:

Hardware Required

to:
Changed lines 74-78 from:
  • AnalogInput - use a potentiometer to control the blinking of an LED
  • AnalogInOutSerial - read an analog pin, map the result, and use that data to dim or brighten an LED
  • Fade - use an analog input to fade an LED
  • Calibration - calibrating analog sensor readings
  • ForLoop - How to use a for() loop (aka Knight Rider)
to:
  • AnalogInOutSerial - Read an analog input pin, map the result, and then use that data to dim or brighten an LED.
  • AnalogInput - Use a potentiometer to control the blinking of an LED.
  • Calibration - Define a maximum and minimum for expected analog sensor values.
  • Fading - Use an analog output (PWM pin) to fade an LED.
  • Smoothing - Smooth multiple readings of an analog input.
July 28, 2015, at 03:26 PM by Simone Maiocchi -
Changed lines 27-28 from:

Connect the longer, positive legs of (anodes) 12 LEDs to digital pins 2-13 through 220 ohm current limiting resistors. Connect the shorter, negative legs (cathodes) to ground.

to:

Connect the longer, positive legs (anodes) of 12 LEDs to digital pins 2-13 through 220 ohm current limiting resistors. Connect the shorter, negative legs (cathodes) to ground.

Added lines 79-80:


Last revision 2015/07/28 by SM

July 07, 2015, at 05:37 PM by Simone Maiocchi -
Changed line 1 from:
to:
July 07, 2015, at 01:28 PM by Simone Maiocchi -
Changed lines 1-4 from:

Examples > Analog

Analog Write with 12 LEDs on an Arduino Mega

to:
Changed line 16 from:
  • hook up wires
to:
  • hook-up wires
July 05, 2015, at 08:58 AM by Simone Maiocchi -
July 05, 2015, at 08:55 AM by Simone Maiocchi -
Changed lines 5-6 from:

This example fades 12 LEDs up and the down, one by one, on an Arduino Mega board.

to:

This example fades 12 LEDs up and the down, one by one, on an Arduino or Genuino Mega board, taking advantage of the increased number of PWM enabled digital pins of this board.

Changed lines 9-12 from:
  • Arduino Mega Board
  • (12) LEDs
  • (12) 220 ohm resistors
  • hook up wire
to:
  • Arduino or Genuino Mega Board
  • 12 Red LEDs
  • 12 220 ohm resistors
  • hook up wires
Changed lines 40-43 from:
to:

for (int thisPin =lowestPin; thisPin <= highestPin; thisPin++)

Changed lines 44-50 from:
to:

for (int brightness = 0; brightness < 255; brightness++) {
analogWrite(thisPin, brightness);
delay(2);
}

Changed lines 51-57 from:
to:

for (int brightness = 255; brightness >= 0; brightness--) {
analogWrite(thisPin, brightness);
delay(2);
}

Changed line 59 from:
to:
May 02, 2012, at 03:41 AM by Scott Fitzgerald -
Changed line 65 from:
to:
November 16, 2011, at 04:11 AM by Scott Fitzgerald -
Changed line 65 from:
to:
September 30, 2011, at 03:10 AM by Scott Fitzgerald -
Changed line 65 from:
to:
September 23, 2010, at 09:14 PM by Christian Cerrito -
Changed line 29 from:
to:
September 17, 2010, at 06:37 PM by Tom Igoe -
Changed line 13 from:
  • bread board
to:
  • breadboard
September 17, 2010, at 06:10 PM by Tom Igoe -
Changed lines 3-4 from:

Example Name

to:

Analog Write with 12 LEDs on an Arduino Mega

September 17, 2010, at 06:10 PM by Tom Igoe -
Changed lines 44-45 from:

moves through each of the LEDS one by one, from the lowest pin to the highest. Before this loop is allowed to move from one pin to the next, two things must be accomplished. First, the individual LED is brightened through these lines of code:

to:

moves through each of the LEDS one by one, from the lowest pin to the highest. Before this loop is allowed to move from one pin to the next, two things must be accomplished. First, you brighten the individual LED through these lines of code:

Added line 50:

}

Added line 59:

}

September 17, 2010, at 06:08 PM by Tom Igoe -
Changed lines 40-41 from:

for (int thisPin =lowestPin; thisPin <= highestPin; thisPin++)

to:
Changed lines 46-47 from:

@@for (int brightness = 0; brightness < 255; brightness++) {

to:
Changed lines 49-50 from:
      delay(2);@@
to:
Changed lines 54-55 from:

@@for (int brightness = 255; brightness >= 0; brightness--) {

to:
Changed lines 57-58 from:
      delay(2);@@
to:
Changed line 74 from:
  • AnalogInOutSerial - read an analog pin, map the result, and use that data to dim or brighten an LED
to:
  • AnalogInOutSerial - read an analog pin, map the result, and use that data to dim or brighten an LED
Deleted line 78:
September 17, 2010, at 06:06 PM by Tom Igoe -
Changed lines 5-6 from:

This example fades12 LEDs up and the down, one by one, on an Arduino Mega board.

to:

This example fades 12 LEDs up and the down, one by one, on an Arduino Mega board.

August 26, 2010, at 08:19 AM by Christian Cerrito -
Changed lines 5-6 from:

Description

to:

This example fades12 LEDs up and the down, one by one, on an Arduino Mega board.

Changed lines 65-66 from:
  • {{Reference/delay]]()
to:
August 26, 2010, at 08:17 AM by Christian Cerrito -
Changed lines 62-63 from:
to:
  • for()
  • analogWrite()
  • {{Reference/delay]]()

  • AnalogInput - use a potentiometer to control the blinking of an LED
  • AnalogInOutSerial - read an analog pin, map the result, and use that data to dim or brighten an LED
  • Fade - use an analog input to fade an LED
  • Calibration - calibrating analog sensor readings
  • ForLoop - How to use a for() loop (aka Knight Rider)

August 26, 2010, at 07:59 AM by Christian Cerrito -
Changed lines 32-33 from:

Describe what's going on here

to:

Code

In the setup() function of the code below, a for() loop is used to assign digital pins 2-13 of the Mega as outputs.

Next, in the loop() function of the program below, a trio of nested for() loops are used.

The first of these loops,

for (int thisPin =lowestPin; thisPin <= highestPin; thisPin++)

moves through each of the LEDS one by one, from the lowest pin to the highest. Before this loop is allowed to move from one pin to the next, two things must be accomplished. First, the individual LED is brightened through these lines of code:

@@for (int brightness = 0; brightness < 255; brightness++) {

      analogWrite(thisPin, brightness);
      delay(2);@@

With each pass through the loop above, the variable brightness increases by one point, and that value is written to the pin currently selected to the main loop. One that pin reaches the maximum PWM value (255), the following loop kicks in:

@@for (int brightness = 255; brightness >= 0; brightness--) {

      analogWrite(thisPin, brightness);
      delay(2);@@

This loop subtracts a point from the brightness variable, dimming the LED back down to 0. Once zero is reached, the main for() loop kicks in, and the program moves on to the next LED pin, repeating all the steps mentioned above.

August 26, 2010, at 07:43 AM by Christian Cerrito -
Added lines 23-24:

Connect the longer, positive legs of (anodes) 12 LEDs to digital pins 2-13 through 220 ohm current limiting resistors. Connect the shorter, negative legs (cathodes) to ground.

August 26, 2010, at 07:39 AM by Christian Cerrito -
Changed lines 9-13 from:
  • Arduino Board
to:
  • Arduino Mega Board
  • (12) LEDs
  • (12) 220 ohm resistors
  • hook up wire
  • bread board
August 26, 2010, at 07:37 AM by Christian Cerrito -
Changed lines 15-16 from:
to:
August 26, 2010, at 07:36 AM by Christian Cerrito -
Changed lines 15-16 from:
to:
August 26, 2010, at 07:35 AM by Christian Cerrito -
Changed lines 15-16 from:
to:
Changed line 23 from:
to:
August 24, 2010, at 08:19 AM by Christian Cerrito -
August 13, 2010, at 10:26 PM by Tom Igoe -
Added lines 1-35:

Share