Tutorial.AnalogWriteMega History

Hide minor edits - Show changes to markup

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