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.

Code:
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);
  }
}
17  Using Arduino / Programming Questions / Re: problem rc receiver signal on: January 23, 2013, 06:52:30 pm
Arrch i'll give that a go
18  Using Arduino / Programming Questions / Re: problem rc receiver signal on: January 23, 2013, 06:46:42 pm
yes but the mid value is not stable and can range a few points around 14435
19  Using Arduino / Programming Questions / Re: problem rc receiver signal on: January 23, 2013, 06:40:32 pm
Tried this no joy

Code:
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);
  }
}
20  Using Arduino / Programming Questions / Re: problem rc receiver signal on: January 23, 2013, 06:32:18 pm
i'll tryif ( 14335 < val && val << 14535) {...
21  Using Arduino / Programming Questions / Re: problem rc receiver signal on: January 23, 2013, 06:31:04 pm
in mid position it is neither therefore the else statement is true??
22  Using Arduino / Programming Questions / Re: problem rc receiver signal on: January 23, 2013, 06:09:13 pm
the three stick positions are giving me three values 14072, 14435 and 14925 (plus or minus 1-6)
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.

Code:
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.
25  Using Arduino / Programming Questions / Re: motor shield current monitoring code on: December 07, 2012, 06:02:09 pm
Will do Paul Thnx.
26  Using Arduino / Programming Questions / Re: simple RC receiver code on: December 07, 2012, 05:27:55 pm
I'm into my first week of learning Arduino so DuaneB's post is rather daunting for me.  If this is the only option then i'll persevere.
27  Using Arduino / Programming Questions / Re: simple RC receiver code on: December 07, 2012, 05:19:37 pm
Pulse in is not the way to go..
28  Using Arduino / Programming Questions / simple RC receiver code on: December 07, 2012, 05:04:51 pm
Does anyone have some simple code for interpreting an rc receiver signal?
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.

Code:
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

Code:
 
  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]
Pages: 1 [2] 3