Been a while...

January 6, 2010

It's been a while since I posted anything, but I finally have made some progress with the Arduino.


Since I'm building my own board eventually for the railroad signals I'm planning, I wanted to prototype a bare-bones Arduino from the ground up... I ordered a '168 from SparkFun, preloaded with the bootloader and then used the schematic and pinouts from to build a minimal setup.

I built a small carrier board to put my resonator on for a good connection, wired it up to a 10mm jumbo LED, got the FTDI USB->Serial board connected and while it didn't work the FIRST time (It took a little tinkering) -- I finally uploaded a sketch and it works as expected - which is no simple feat for me right now for the amount of time I have of late...


After I got the Hello Blinky LED sketch running, I did tinker around with a sketch to set the brightness of the LED based on values from the serial port and that worked, too!

At any rate, progress in the forward direction!

  Based on Examples, sets the LED brightness based on a numeric value received by the
  serial port.


const int ledPin = 9;      // the pin that the LED is attached to

void setup()
  // initialize the serial communication:
  // initialize the ledPin as an output:
  pinMode(ledPin, OUTPUT);

void loop() {
  byte brightness;
  byte character;

  // check if data has been sent from the computer:
  if (Serial.available()) {
    // read the most recent byte (which will be from 0 to 255):
    character =;

    // check to see if the character is a ASCII Number between 0 and 9   
    if (character >= 48 && character <=57)
      // fix the ASCII value to match the actual value
      // i.e. 0 = 0, 9 = 9
      character = character - 48;
      // scale the input values to light the LED. 
      //  chose scale value is 28
      //  i.e. 1*28 = 28, 9*28 = 252 (almost 255, close enough for this)
      brightness = character * 28;

    // set the LED's brightness:
    analogWrite(ledPin, brightness);