JediPuju
New Member
- Joined
- Jun 9, 2009
- Messages
- 47
Ive been dormant here for a while but Ive been mucking around with PICs and electronics etc for my models, and with the release of the mobius cylon raider out there (quaralane kicking off nicely I see) I thought this would be an Ideal little project to flex my programming.
I started my refit enterprise circuit in MPASM assembler. But I also bought an Arduino nano at the time I bought my Pickit 3 to see what the fuss is all about. Well In about an hour and with absolutely no previous experience with arduino (but I do program lots for work) I had a decent prototype up and running! MUCH easier than assembler! 8)
Got the roving eye working with a nice fade either side, and also a couple of leds which have a nice subtle flicker to them for the engines (doesnt show well in the video unfortunately). Might tweak the animation slightly but its a good start for someone.
CylonEye
And here is the code if you wish to try this out:
/*
CylonEye
Simple Sketch for Cylon Kits
Lee Fitzsimmons March 2012
You are free to use this code as you wish,
Just dont blame me if something blows up
*/
//num2pin contains maps the position in the pattern to its pin num
int num2pin[] = {3,5,6,9,10,11};
//pins for the engines
int engine1 = 7;
int engine2 = 8;
//the animation frames in an array.
int sweep[][6] = {
{255,60,10,0,0,0},
{60,255,60,10,0,0},
{10,60,255,60,10,0},
{0,10,60,255,60,10},
{0,0,10,60,255,60},
{0,0,0,10,60,255},
{0,0,10,60,255,60},
{0,10,60,255,60,10},
{10,60,255,60,10,0},
{60,255,60,10,0,0}
};
int seqlen = 10;
int statelen = 5;
int curseq = 0;
unsigned long time;
unsigned long prevtime = 0;
unsigned long interval = 80;
void setup() {
//pwm pins dont require setting direction
pinMode(engine1, OUTPUT);
pinMode(engine2, OUTPUT);
randomSeed(analogRead(0));
}
void loop() {
//we use the running time in miliseconds to determine the
//speed at which the animation runs
time = millis();
if(time - prevtime > interval) {
prevtime = time;
//set each led to the current animation 'frame'
for(int t=0; t <= statelen; t++) {
analogWrite(num2pin[t], sweep[curseq][t]);
}
//increment frame, loop if at end
curseq++;
if(curseq > seqlen -1) {
curseq = 0;
}
}
//engines
int rand = random(255);
analogWrite(engine1, rand);
rand = random(255);
analogWrite(engine2, rand);
}
Keep Jumpin', and watch out for those frakkin' toasters ;D
I started my refit enterprise circuit in MPASM assembler. But I also bought an Arduino nano at the time I bought my Pickit 3 to see what the fuss is all about. Well In about an hour and with absolutely no previous experience with arduino (but I do program lots for work) I had a decent prototype up and running! MUCH easier than assembler! 8)
Got the roving eye working with a nice fade either side, and also a couple of leds which have a nice subtle flicker to them for the engines (doesnt show well in the video unfortunately). Might tweak the animation slightly but its a good start for someone.
CylonEye
And here is the code if you wish to try this out:
/*
CylonEye
Simple Sketch for Cylon Kits
Lee Fitzsimmons March 2012
You are free to use this code as you wish,
Just dont blame me if something blows up
*/
//num2pin contains maps the position in the pattern to its pin num
int num2pin[] = {3,5,6,9,10,11};
//pins for the engines
int engine1 = 7;
int engine2 = 8;
//the animation frames in an array.
int sweep[][6] = {
{255,60,10,0,0,0},
{60,255,60,10,0,0},
{10,60,255,60,10,0},
{0,10,60,255,60,10},
{0,0,10,60,255,60},
{0,0,0,10,60,255},
{0,0,10,60,255,60},
{0,10,60,255,60,10},
{10,60,255,60,10,0},
{60,255,60,10,0,0}
};
int seqlen = 10;
int statelen = 5;
int curseq = 0;
unsigned long time;
unsigned long prevtime = 0;
unsigned long interval = 80;
void setup() {
//pwm pins dont require setting direction
pinMode(engine1, OUTPUT);
pinMode(engine2, OUTPUT);
randomSeed(analogRead(0));
}
void loop() {
//we use the running time in miliseconds to determine the
//speed at which the animation runs
time = millis();
if(time - prevtime > interval) {
prevtime = time;
//set each led to the current animation 'frame'
for(int t=0; t <= statelen; t++) {
analogWrite(num2pin[t], sweep[curseq][t]);
}
//increment frame, loop if at end
curseq++;
if(curseq > seqlen -1) {
curseq = 0;
}
}
//engines
int rand = random(255);
analogWrite(engine1, rand);
rand = random(255);
analogWrite(engine2, rand);
}
Keep Jumpin', and watch out for those frakkin' toasters ;D