Pages: 1 [2]   Go Down
Author Topic: (solved) problem reading data from rc receiver  (Read 1101 times)
0 Members and 1 Guest are viewing this topic.
BCC AZ USA
Offline Offline
Edison Member
*
Karma: 33
Posts: 1135
It gets hot so it must be working
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I cleaned it up a bit.  This should work.

Code:
const byte ch1 = 3;
const byte led = 13;

void setup() {
  pinMode(ch1, INPUT);
  pinMode(led, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  int width = pulseIn(ch1, HIGH, 30000);
  Serial.print("Channel 1:  ");
  Serial.println(width);       
  if(width > 1800) {
     digitalWrite(led, HIGH);
  }

Serial.println();
delay(100);
}
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thank you!!!! but i did have to make a change. i changed it to pin 11 as the led output and it works! maybe something is wrong with pin 13 on my board here is the finished code i added a line to turn the led back off

Code:
const byte ch1 = 3;
const byte led = 11;

void setup() {
  pinMode(ch1, INPUT);
  pinMode(led, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  int width = pulseIn(ch1, HIGH, 30000);
  Serial.print("Channel 1:  ");
  Serial.println(width);       
  if(width > 1990) {
     digitalWrite(led, HIGH);
  }
     if(width < 1800) {
     digitalWrite(led, LOW);
  }
}

« Last Edit: October 24, 2013, 08:31:15 pm by jeremybgilbert » Logged

BCC AZ USA
Offline Offline
Edison Member
*
Karma: 33
Posts: 1135
It gets hot so it must be working
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yeah, I realized that as soon as you said the led wasn't coming on.  Congrats.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 39
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thank you so much for your help! you are awesome lol now im going to edit it to have three channels since i have three spare channels on my receiver.
Logged

Pages: 1 [2]   Go Up
Jump to: