Raynerd.co.uk

10 Feb, 2010

Bi-colour LED Blinker - 12F675

Posted by: admin In: Bi-colour LED Blinker

A very simple project but it makes a nice introduction to coding! It is actually just two pins at logic 1 independently and then together so on the development board it is simply two leds flashing but if you put it with a bi-colour led (maplin sell these as tri-colour but they are actually only two colours R&G, true tri-colour is RGB) it looks quite nice.

I`m sure you`ll get the idea after a few seconds! :lol:

Simple flashing:


#define red GPIO.b0
#define green GPIO.b1
int i=500;
char cnt;
void init()
{
ANSEL = 0; // Configure AN pins as digital
CMCON = 7; // Turn off the comparators
TRISIO = 0; // configure pins of GPIO as output
GPIO = 0x00;
}

void main()
{
init ();

while (1)
{
red = 1;
green=0;
delay_ms(200);
red = 0;
green = 1;
delay_ms(200);
red = 1;
delay_ms(200);
}
}

Alternative shown in the video with a nice looking delay that speeds up:


#define red GPIO.b0
#define green GPIO.b1
int i=500;
char cnt;
void init()
{
ANSEL = 0; // Configure AN pins as digital
CMCON = 7; // Turn off the comparators
TRISIO = 0; // configure pins of GPIO as output
GPIO = 0x00;
}

void main()
{
init ();

while (1)
{
i = i-40;
if (i <= 0)
i = 500;
else
{
red = 1;
green=0;
Vdelay_ms(i);
red = 0;
green = 1;
Vdelay_ms(i);
red = 1;
Vdelay_ms(i);
if (i <200)
{
red = 1;
green=0;
Vdelay_ms(i);
red = 0;
green = 1;
Vdelay_ms(i);
red = 1;
Vdelay_ms(i);
}
if (i<100)
{
for (cnt=0; cnt<80; cnt++)
{
red = 1;
green=0;
Vdelay_ms(i);
red = 0;
green = 1;
Vdelay_ms(i);
red = 1;
Vdelay_ms(i);
}
}
}
}
}

No Responses to "Bi-colour LED Blinker - 12F675"

Comment Form


  • admin: I appreciate your interest in this project. I have far too many other little projects on the go and have just had a major change around, reorganisatio
  • Mark Peterson: What is your current status? Any advances since July? I am curious to see how you end up on this project. This has got to be a labor of love. I endeav
  • admin: Yes, I machined the graphite. It was very messy! I`ve tried it without the counter weight and still nothing. It is currently in bits again and I`m mak

Welcome to Raynerd.co.uk

I`ve always wanted to learn more about engineering and electronics and my list of projects both complete and ongoing has been growing over the past few years. I like to document my progress more for my own understanding as much as anything, it helps keep me on track. I hope you can find something of interest to you, my clock building project is my priority but as you can see, I have many other builds I`m working on. Please leave a comment, it is nice to see people are reading!