If you guys haven’t sharpen your coding skills, this is the place to challenge them. Doesn’t hurt to go back to basics to reinforce your foundations, plus the coursework is meant to be taken at your own pace. Give Udacity a try!

engineeringisawesome
anengineersaspect:

ENGINEERING QUOTE OF THE WEEK - YUAN CHENG (“BERT”) FUNG
Engineering is quite different from science. Scientists try to understand nature. Engineers try to make things that do not exist in nature. Engineers stress invention. To embody an invention the engineer must put his idea in concrete terms, and design something that people can use. That something can be a device, a gadget, a material, a method, a computing program, an innovative experiment, a new solution to a problem, or an improvement on what is existing. Since a design has to be concrete, it must have its geometry, dimensions, and characteristic numbers. Almost all engineers working on new designs find that they do not have all the needed information. Most often, they are limited by insufficient scientific knowledge. Thus they study mathematics, physics, chemistry, biology and mechanics. Often they have to add to the sciences relevant to their profession. Thus engineering sciences are born.                                                                                       ~Yuan-Cheng (“Bert”) Fung(Y.C. Fung and P. Tong, Classical and Computational Solid Mechanics (2001), 1.)
http://anengineersaspect.blogspot.com/2013/06/engineering-quote-of-week-yuan-cheng.html

anengineersaspect:

ENGINEERING QUOTE OF THE WEEK - YUAN CHENG (“BERT”) FUNG

Engineering is quite different from science. Scientists try to understand nature. Engineers try to make things that do not exist in nature. Engineers stress invention. To embody an invention the engineer must put his idea in concrete terms, and design something that people can use. That something can be a device, a gadget, a material, a method, a computing program, an innovative experiment, a new solution to a problem, or an improvement on what is existing. Since a design has to be concrete, it must have its geometry, dimensions, and characteristic numbers. Almost all engineers working on new designs find that they do not have all the needed information. Most often, they are limited by insufficient scientific knowledge. Thus they study mathematics, physics, chemistry, biology and mechanics. Often they have to add to the sciences relevant to their profession. Thus engineering sciences are born.
                                                                                       ~Yuan-Cheng (“Bert”) Fung

(Y.C. Fung and P. Tong, Classical and Computational Solid Mechanics (2001), 1.)

http://anengineersaspect.blogspot.com/2013/06/engineering-quote-of-week-yuan-cheng.html

Bi-Color LED Fading (Red <- Orange -> Green) Sketch

My first coding experience with an Uno is a vivid reminder why thorough planning is a key to successful completing projects. I have electronic parts laying around my room for another project and figured why not code my first sketch from using them. It basically takes a bi-color LED and fades from orange to red, then back to orange, and then green, and at last back to orange. It only requires couple of wires, a breadboard, 1k ohm resistor, and a bi-color LED.

image

Initial Setup

My code is base off of the blink program included with the Arudino IDE, but for some odd reason I had trouble figuring out how do I do the switching fade. Also I came to a realization why those swiggles next to certain numbers, as described by Ben Heck in the video below…

Took awhile (half a day, WTF?), but I managed to complete it. Below is the code I created; feel free to modify it at your will. I’m thinking of creating an interrupt version for more efficient code.

/*
 Red, Green, and Orange Fade
 4 Sep 2013
 beatsgo

 An add-on to the fade led example from Arduino
 This incorporates a Bi-Color LED (Red and Green) to fade in and out
 from red to green and vise-versa. This is realized by initializing the LEDs to maximum voltage, then
 fading one color at a time.
 Remember, because there’s a “varying” voltage the signal is very much analog requiring the LED to hookup
 to a PWM port. This is why I am using pins 10 & 9.

 Serial code is added for debugging purposes
 */

/*
  Global Variables
  Variables which can be viewed and used in any function at any given time
  Remember they are global, so if you don’t want to have their values changed at all,
  pre-syntax const (constant) before defined data type will retain it’s intial value for good.
*/
const int green_led = 10;     // green led assigned to pin 10
const int red_led = 9;       // red led assigned to pin 9
const int int_bright = 255;    // intially how bright the LED is
int light = int_bright;
int fadeAmount = -5;
boolean color_change = 1; // 0 = green, 1 = red

/*
  Prototype Functions
  Defining functions within and outside of the scope of the project
*/
void switchup(int bright);

// Intialization and Setup section
void setup() 
{
  //setup serial communication at 9600 bps
  Serial.begin(9600);

  // defines pins 10 & 9 as output pins
  pinMode(green_led, OUTPUT);
  pinMode(red_led, OUTPUT);
  Serial.println(“Pins 8 and 9 are set to output”);

  // Intiailize pins 10 & 9 to output voltage
  analogWrite(green_led, int_bright);
  analogWrite(red_led, int_bright);
//  Serial.print(“Green and red LED outputting “);
//  Serial.println(int_bright); 
}

void switchup(int bright)
{
    if(bright == 0)
      fadeAmount = -fadeAmount;
}


// main program loop
void loop() 
{
  while(light <= 255)
  {
    if(color_change != true)
    {
      analogWrite(green_led, light);
//      Serial.print(“Green LED currently outtputing at “);
      Serial.println(light);       
      delay(30);
    }
    else
    {
      analogWrite(red_led, light);
//      Serial.print(“Red LED currently outtputing at “);
      Serial.println(light);       
      delay(30);
    }
    switchup(light);
    light += fadeAmount;
  }

  //Reset variables
  light = int_bright;
  fadeAmount = -fadeAmount;
  color_change = !color_change; //Flip to next color fade
}

image

Final Setup

If you have any questions or comments feel free to ask!