Show Posts
|
|
Pages: 1 [2] 3
|
|
16
|
Using Arduino / Programming Questions / Re: problem rc receiver signal
|
on: January 23, 2013, 06:57:35 pm
|
Guys, Arrch this worked. int rcpin =7; int motpin = 13; const int THRESHOLD = 5;
void setup() { Serial.begin(9600); pinMode(rcpin, INPUT); pinMode(motpin, OUTPUT); }
int val;
void loop()
{ val = pulseIn(rcpin, INPUT); Serial.println(val); delay(1000); Serial.println(val); // if ((val > 14535) && (val < 14335)) //if ( 14335 < val || val > 14535) if ( (val > 14435 - THRESHOLD) && (val < 14435 + THRESHOLD) ) { digitalWrite(motpin, LOW); } else { digitalWrite(motpin, HIGH); } }
|
|
|
|
|
19
|
Using Arduino / Programming Questions / Re: problem rc receiver signal
|
on: January 23, 2013, 06:40:32 pm
|
Tried this no joy int rcpin =7; int motpin = 13;
void setup() { Serial.begin(9600); pinMode(rcpin, INPUT); pinMode(motpin, OUTPUT); }
int val;
void loop()
{ val = pulseIn(rcpin, INPUT); Serial.println(val); delay(1000); Serial.println(val); // if ((val > 14535) && (val < 14335)) if ( 14335 < val || val < 14535) { digitalWrite(motpin, LOW); } else { digitalWrite(motpin, HIGH); } }
|
|
|
|
|
23
|
Using Arduino / Programming Questions / problem rc receiver signal
|
on: January 23, 2013, 05:50:34 pm
|
Can anyone see anything wrong with this simple code. Arduino uno, expect the LED on pin 13 to be on or of dependant on the position of the control stick on the rc transmitter. regardless of the stick position the LED remains on. int rcpin =7; int motpin = 13;
void setup() { Serial.begin(9600); pinMode(rcpin, INPUT); pinMode(motpin, OUTPUT); }
int val;
void loop()
{ val = pulseIn(rcpin, INPUT); Serial.println(val); delay(1000); if ((val > 14535) && (val < 14335)) { digitalWrite(motpin, LOW); } else { digitalWrite(motpin, HIGH); } } the value is changing when the rc transmitter switch is operated. mid value is 14435 with the full deflections reading 14072 + or - a couple of points and 14926 + or - respectively
|
|
|
|
|
24
|
Using Arduino / Programming Questions / Re: motor shield current monitoring code
|
on: January 23, 2013, 05:40:13 pm
|
|
sorry for not getting back on the forum for a while. yes have made great progress with this and have got the U/C to work well the gear doors open, gear lowers and stop at the end of travel with the stall current of the motor being read by the Arduino, then the gear doors close. Works well. Have used a component to convert the rc signal to a digital 5v or 0v. This has now proved unreliable so now trying to get the arduino to read the pwm. have found some great motors for the job.
|
|
|
|
|
29
|
Using Arduino / Programming Questions / Re: motor shield current monitoring code
|
on: December 07, 2012, 04:16:36 pm
|
Yep got it running well now. Here's the code. I've got the motor running back and forth until i apply a high load near the stall value and above the limit i set and the motor pauses for 7000`ms. Cracking. Thanks Gys, thanks DC. I'll see if i can build this into an RC signal now to switch on and off. int Bbrake=8;//brake signal for motor B int Abrake=9;//brake signal for motor A int motorspdB=11;//PWM speed signal for motor B int motorspdA=3;//PWM speed signal for motor A int motorA=12; int motorB=13; int sensorPinB = A1; // select the input pin for the current int sensorValue = 0; // variable to store the value coming from the sensor //int limit=A0
void setup () { pinMode (13, OUTPUT);//motor B enable and direction HIGH or LOW pinMode (12, OUTPUT);//motor A enable and direction HIGH or LOW pinMode (8, OUTPUT);//Brake motor B pinMode (9, OUTPUT);//Brake motor A Serial.begin(9600);//start serial print monitor
} void loop () { int limit =110; //Value that triggers motor to shutoff once it has reached endpoint analogWrite (motorspdB,255); digitalWrite (motorB,HIGH); digitalWrite (Bbrake,LOW); delay(1000); sensorValue = analogRead(sensorPinB); Serial.println(sensorValue); delay(1000); if (sensorValue>limit) { digitalWrite (Bbrake,HIGH); delay(500); analogWrite (motorspdB,0); digitalWrite (Bbrake,LOW); delay(7000); } digitalWrite (motorB,LOW); digitalWrite (Bbrake,LOW); delay(1000); }/code]
|
|
|
|
|
30
|
Using Arduino / Programming Questions / Re: motor shield current monitoring code
|
on: December 07, 2012, 03:53:38 pm
|
Think i just worked it out. Sensor value =analogRead needed to be before serial print analogWrite (motorspdB,255); digitalWrite (motorB,HIGH); digitalWrite (Bbrake,LOW); delay(2000); sensorValue = analogRead(sensorPin); Serial.println(sensorValue); delay(2000); if (sensorValue>limit) { digitalWrite (Bbrake,HIGH); delay(5000);/code]
|
|
|
|
|