Fading LED Connected to PWM Pin

First stab at creating a tutorial...

I've been playing around with Arduino recently. Ultimately the goal of my tinkering is to create a motorized body for my pi in the sky project. The Raspberry pi will serve as the brain, and the arduino will be the body. Here's a small circuit project I put together so I could test the capability of the GPIO pins on the arduino and get an idea of what this environment is all about. I used the book "Getting Started with Arduino" to put this together, if you want to view or download a free version of that book, just click the link or the image of the book next to this text!


The Code:

This code is usually in C/C++ and it should be saved as a ".ino" extension. If you would like to download the code, go to my Fritzing page (button below)

const int LED = 9; // the pin for the LED
int i = 0;         // We'll use this to count up and down

void setup() {
  pinMode(LED, OUTPUT); // tell Arduino LED is an output
}

void loop(){
  for (i = 0; i < 255; i++) { // loop from 0 to 254 (fade in)
    analogWrite(LED, i);      // set the LED brightness
    delay(10); // Wait 10ms because analogWrite is instantaneous and we would not see any change
  }

  for (i = 255; i> 0; i--) { // loop rom 255 to 1 (fade out)

    analogWrite(LED, i); // set the LED brightness
    delay(10);           // Wait 10ms
  }
}

Kick the arduino projects into high gear... 

...get it?

Let's get this thing moving...

Recently I got this book out of the library and I'm going to start going through some of these projects as soon as I get some time. I've been working on Question Combat for the past few weeks, but I'll dive back into this soon. Stay tuned!

The Arduino Cookbook

The Arduino Cookbook

The Arduino UNO

The Arduino UNO