About Me

currently on the way to become a mechanical engineer. here are the things that I do on the way.

Build and Hack Stuff

[KR-A]: Arduino Beginnings – RGB LEDs – Rv0.1

My latest prefix is KR-A in which the ‘A’ stands for ‘Arduino’

The beginning of this series is “Arduino Beginnings” as it will demonstrate my earlier projects and encounters stepping into the Arduino world.

My Arduino of choice is the Arduino Uno with the ATmega328 onboard. Along with my Arduino, I picked up Getting Started with Arduino  by Massimo Banzi.

The book starts off with the “hello world” kind of stuff, and really shows what’s going on during the first encounter. Having gone through most of the book now, I’m ready to start exploring the vast internet for project ideas, and resources.

Today I read a little bit from the tutorials on ladyada.net found here. I decided to make my own version of what the tutorial is teaching, and design a sketch that lights red, green, and blue in that order.

bleep

The Point

The main point was to be able to create a working sketch on my own without having to type verbatim what was in a book or on a website. Even though I still got most of the snippets and ideas from the tutorial, It’s still my own version. This is a very important element in my learning process.

The Sketch

// KR-Tech
// http://www.kr-tech.net
//
// RGB Lamp A
//
//
//

int redPin = 12; // Red LED connected to digital pin 12
int greenPin = 11; // Green LED connected to digital pin 11
int bluePin = 10; // blue LED connected to digital pin 10

void setup()
{
pinMode(redPin, OUTPUT); // sets the digital pin as output
pinMode(greenPin, OUTPUT); // sets the green digital pin as output
pinMode(bluePin, OUTPUT); // Sets the green digital pin as output
}

void loop() // repeat over and over
{
digitalWrite(redPin, HIGH); // turn red ON
delay(250); // wait .25"

digitalWrite(redPin, LOW); // turn red OFF
digitalWrite(greenPin, HIGH); // turn green ON
delay(250); // wait .25"

digitalWrite(greenPin, LOW); // turn green OFF
digitalWrite(bluePin, HIGH); // turn blue ON
delay(250); // wait .25"

digitalWrite(bluePin, LOW); // turn blue OFF
}

What It Does

First we assign the pins to LEDs, then we tell Arduino what each pin is supposed to do. After that we create a loop that turns a single LED on, waits a quarter of a second, turns it off and moves to the next LED.

Very simple project, but it made a happy little set of blinking lights for me to write this post to.

Comments are closed.