Pages: [1]   Go Down
Author Topic: Newbie code check, RF transmit  (Read 344 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Full Member
***
Karma: 0
Posts: 152
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

Could someone knowledgeable check over my code? I am using an RF pair from Sparkfun.

The transmitter is this one: RF Link Transmitter - 434MHz

Here is the code I am using to transmit to another Arduino with the receiver on board.

Code:
//pins

const int tripBeam=6;//input from an IR trip beam

const int LED=13;//output - LED that conveys status to humans



//constants

const byte GO=210;//Send this through serial, which will go wirelessly to another Arduino. Picked pretty much at random.



//durations

unsigned long deadTime=5000;//don't bother listening to the trip beam for 5 seconds after it's tripped



void setup(){

Serial.begin(2400);//2400 baud for the 434 chip

pinMode(tripBeam, INPUT);

pinMode(LED, OUTPUT);

digitalWrite(tripBeam, HIGH);//turn on internal 20k pullup resistor so the open input state is HIGH.

digitalWrite(LED, LOW);

}



void loop(){

//See if the trip beam has been tripped

if(digitalRead(tripBeam)==LOW){

Serial.print(GO);

digitalWrite(LED, HIGH);

delay(deadTime);

digitalWrite(LED, LOW);

}

}



When I trigger the switch (tripBeam=6), the LED blinks and the serial monitor shows "Ò".

The input is from a separate IR receiver. It has a dip relay, N/O to pin 6, COM to ground.

Any help would be very much appreciated.

 smiley
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26627
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So,what's the problem?
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Full Member
***
Karma: 0
Posts: 152
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

Receiver is not receiving. I thought I'd ask to see if there are any glaring errors in the transmitting code first.

Is the "Ò" in the serial monitor what would be expected with successful transmission?

Thanks
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 310
Posts: 26627
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Is the "Ò" in the serial monitor what would be expected with successful transmission?
I don't know; values above 127 are not ASCII, so you'd have to look for the character  code 210.

If you're on a PC, you could run "charmap" - yes, 0xd2 is capital O grave.
« Last Edit: August 19, 2011, 02:44:53 pm by AWOL » Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Full Member
***
Karma: 0
Posts: 152
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The problem has been solved. Thanks to those who helped  smiley
Logged

Pages: [1]   Go Up
Jump to: