Tuesday, January 24, 2012

First program on microcontroller.

First I was able to load and run a simple code.

Then I modified the code some to run 4 led's with simple delays to turn off or on the next light. this just lets me know I am able to write a program and load it into the controller. The following picture shows the Arduino software I use to load the program to the Teensy Microcontroller. I inserted the actual code next.

_____________________________

/* RGB LED Blink, Teensyduino Tutorial #2
http://www.pjrc.com/teensy/tutorial2.html

This example code is in the public domain. Jim's info - for teensy 2.0. Will blink each light for 400 ms
*/

const int builtinPin = 11;
const int yellowPin = 12;
const int redPin = 14;
const int greenPin = 15;

// The setup() method runs once, when the sketch starts

void setup() {
// initialize the digitals pin as an outputs
pinMode(builtinPin, OUTPUT);
pinMode(yellowPin, OUTPUT);
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
}

// the loop() method runs over and over again,

void loop()
{
digitalWrite(builtinPin, HIGH);
delay(1000);
digitalWrite(yellowPin, HIGH);
delay(1000);
digitalWrite(redPin, HIGH);
delay(1000);
digitalWrite(greenPin, HIGH);
delay(2000);
digitalWrite(builtinPin, LOW);
delay(1000);
digitalWrite(yellowPin, LOW);
delay(1000);
digitalWrite(redPin, LOW);
delay(1000);
digitalWrite(greenPin, LOW);

delay(2000);
}

___________________________________________

The following is a video of the actual output.


No comments:

Post a Comment