SparkFun Variations – Part 1

Posted: December 4th, 2010 | Author: | Filed under: Arduino | No Comments »

This is a first in a series of posts that feature variations on the code samples provided in the SparkFun Inventor’s Guide.

Lesson: CIRC-01 Getting Started – (Blinking LED)
Hardware Changes: I moved the LED from pin 13 (digital) to pin 9 (analog). You can read more about analog pins here.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
int pinNumber = 9;
 
void setup() {                
  pinMode(pinNumber, OUTPUT);
  Serial.begin(9600);
}
 
void loop() {
  digitalBlinkPulse(pinNumber);
  delay(250);              
  analogFadeInThenOut(pinNumber);
  delay(250);
}
 
void analogFadeInThenOut(int pinNumber){
  int maxValue = 255;
  int increment = 10;
  int delayMs = 5;
  for(int i = 0; i < maxValue; i=i+increment){
     analogWrite(pinNumber, i);
     delay(delayMs);              
  }
  for(int i = maxValue; i > 0; i=i-increment){
     analogWrite(pinNumber, i); 
     delay(delayMs);              
  }
  analogWrite(pinNumber, 0); 
}
 
void digitalBlinkPulse(int pinNumber){
  int increment = 10;
  int maxValue = 100;
  for(int i = 0; i < maxValue; i=i+increment){
    digitalWrite(pinNumber, HIGH);   
    delay(i);              
    digitalWrite(pinNumber, LOW);    
    delay(i);              
  }
  for(int i = maxValue; i > 0; i=i-increment){
    digitalWrite(pinNumber, HIGH);   
    delay(i);              
    digitalWrite(pinNumber, LOW);    
    delay(i);              
  }
}

Arduino Get!

Posted: December 2nd, 2010 | Author: | Filed under: Arduino | No Comments »

The other day FedEx delivered an early Christmas present…a SparkFun Inventor’s Kit for Arduino. The Arduino is a physical computing platform that you can attach components and circuits to to make it do cool stuff. The Inventor’s Kit includes an Arduino, a breadboard, a starter guide with lessons, motors, LEDs, servos and a host of other parts.

Here’s an entertaining introduction to the Arduino…

I’m working through the lessons now and I have to say that it’s a joy to be write code that interacts with the physical space.

Source code and videos to follow!

More Info

  • Read more about the Arduino.
  • Head over to YouTube to see a host of Arduino-powered creations.
  • Buy the SparkFun Inventor’s Kit from the cool cats at SparkFun Electronics.