I got the code all written up, and gave it a test with two multimeters hooked up to the outputs (Unfortunately this video is really dark, it looked lighter when I was taking it)
#define in1 3
#define pwm1 9
#define f1 5
#define b1 7
#define in2 4
#define pwm2 10
#define f2 6
#define b2 8
void setup()
{
// Channel 1:
pinMode(in1,INPUT);
pinMode(pwm1,OUTPUT);
pinMode(f1,OUTPUT);
pinMode(b1,OUTPUT);
// Channel 2:
pinMode(in2,INPUT);
pinMode(pwm2,OUTPUT);
pinMode(f2,OUTPUT);
pinMode(b2,OUTPUT);
Serial.begin(9600);
}
void loop()
{
int p1=pulseIn(in1,HIGH);
int p2=pulseIn(in2,HIGH);
int p3=p1+p2-1500;
int p4=p1-p2+1500;
p1 = constrain(p3, 1200, 1800);
p2 = constrain(p4, 1200, 1800);
//============= Channel 1 =============
if(p1 > 1530)
{
int s1=map(p1, 1530, 1800, 255, 0);
analogWrite(pwm1,s1);
digitalWrite(b1,LOW);
digitalWrite(f1,HIGH);
}
else if(p1 < 1470)
{
int s1=map(p1, 1470, 1200, 255, 0);
analogWrite(pwm1,s1);
digitalWrite(f1,LOW);
digitalWrite(b1,HIGH);
}
else
{
analogWrite(pwm1,255);
digitalWrite(b1,LOW);
digitalWrite(f1,LOW);
}
//============ Channel 2 ==============
if(p2 > 1530)
{
int s2=map(p2, 1530, 1800, 255, 0);
analogWrite(pwm2,s2);
digitalWrite(b2,LOW);
digitalWrite(f2,HIGH);
}
else if(p2 < 1470)
{
int s2=map(p2, 1470, 1200, 255, 0);
analogWrite(pwm2,s2);
digitalWrite(f2,LOW);
digitalWrite(b2,HIGH);
}
else
{
analogWrite(pwm2,255);
digitalWrite(b2,LOW);
digitalWrite(f2,LOW);
}
//====================================
delay(15);
}
For my actual outdoor run, in order to get some footage, I made up a quick little camera bracket for my transmitter, I call it the "forever alone camera mount"
And I also made a little mount for my action cam to mount on PK in place of the paintball gun, since I do not yet have the necessary parts to make it opperational yet.
And with all that set up and working, I went out and drove it around my driveway for a bit (woohoo, my first legitimate run :)) The first video is me filming, and the second is from PK's camera
Motor controller:
Arduino:
The whole backside:
And from the front,
Top,
And side:
Anyway, it runs, which brings a smile to my face :) Onward and upward!!
No comments:
Post a Comment