Just the nudge I needed to get going

I have been wanting to get into playing around with Arduino for quite some time. However, for what ever reason I have not taken the plunge and ordered an Arduino board.

That was until recently, a friend asked if I’d be interested in programming up a project for her, which just so happens to be using Arduino. Well, how could I resist. Needless to say, that got me quickly buying my first board and pulling out the ideas for projects that I’d been sitting on for quite some time.

Now, I know there are possibly thousands of how-tos and other code / project information sites for Arduino and some I may replicate in my own way so I figure, here is where I’ll share them.

I have a raft of projects on my to-do list, but to get my head around coding for Arduino I built up a little and very simple LED circuit on a bread board and hooked up my Arduino UNO, to which I put the following source code for a set of “traffic lights”

Feel free to pillage, steal and otherwise use the following for your own projects, Model Railway possibly or even a slot car set, end of your driveway.

this sequence also monitors the internal temperature of the Arduino chip and changes the lights to “Broken” (flashing yellow) if the temperature gets too high (over 18 degrees Celsius). Try setting the temp lower as my Arduino UNO very rarely gets above 12 degrees.

[code lang=”c”]// Basic Traffic Light Controller
// Coded by Kimberly – http://kimmynz.com

const int LightsareGreen = A0;
const int LightsareOrange = A1;
const int LightsareRed = A2;

double t;

void setup(){
pinMode(LightsareGreen, OUTPUT);
pinMode(LightsareOrange, OUTPUT);
pinMode(LightsareRed, OUTPUT);
}

void loop()
{
while (t > 18)
{
ChangetoBroken();
}
ChangetoGreen();
delay(15000);
ChangetoOrange();
delay(3000);
ChangetoRed();
delay(15000);
}

void ChangetoGreen()
{
digitalWrite(LightsareGreen, HIGH);
digitalWrite(LightsareOrange, LOW);
digitalWrite(LightsareRed, LOW);
}

void ChangetoOrange()
{
digitalWrite(LightsareGreen, LOW);
digitalWrite(LightsareOrange, HIGH);
digitalWrite(LightsareRed, LOW);}

void ChangetoRed()
{
digitalWrite(LightsareGreen, LOW);
digitalWrite(LightsareOrange, LOW);
digitalWrite(LightsareRed, HIGH);}

void ChangetoBroken()
{
int x = 1;
for (x = 1; x < 10; x++)
{
Serial.print(t);
Serial.print((char)176);
Serial.println(“C”);
digitalWrite(LightsareGreen, LOW);
digitalWrite(LightsareOrange, HIGH);
digitalWrite(LightsareRed, LOW);
delay(700);
digitalWrite(LightsareGreen, LOW);
digitalWrite(LightsareOrange, LOW);
digitalWrite(LightsareRed, LOW);
delay(700);
GetTemp();
}
}
double GetTemp(void)
{
unsigned int wADC;
//

About kimberly 190 Articles

I’m an Electronics Service Technician by day. By night I’m an Application Developer, Embedded Software Developer, Mountain Biking chic. Currently starting to put together some home automation projects which I’ll be posting progress on the site.

Be the first to comment

Leave a Reply