Pages: [1]   Go Down
Author Topic: RF transmitter and reciver  (Read 431 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am creating something like a key finder on my arduino. I plan to push a button turning on the transmitter. The receiver will connect to a second arduino which will have a if x >y statement. When the transmitter is on this statement should turn on a buzzer. I feel as though this code makes logical sense however all the research I've done on RF transmitting with arduinos always are very complex and include the TX and RX slots. I am new to this and only roughly understand their function so would prefer to stay away from them. Can anyone tell me if a normal analog imput will work for just telling an arduino if the transmitter is on? And if so does the rest of the code sound alright?

TRANSMITTER
const int switchPin = 2
const int rftransPin = 8

int switchState = 0

void setup() {
  // put your setup code here, to run once:
  pinMode(switchPin, INPUT);
  pinMode(rftransPin, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  switchState = digitalRead(SwitchPin);
  if (switchState == HIGH) {
    digitalWrite(rftransPin, HIGH);
  }
  else {
    digitalWrite(rftransPin, LOW);



Reciver
const int buzzerPin = 2
const int rfrecPin = A1

int rfrecState = 0

void setup() {
  pinMode(buzzerPin, OUTPUT);
}

void loop() {
  rfrecValue = analogRead(rfrecPin);
 
  if(rfrecValue > 150)
    digitalWrite(buzzerPin, HIGH);
  if(rfrecValue < 150)
    digitalWrite(buzzerPin, LOW);
Logged

the land of sun+snow
Offline Offline
Faraday Member
**
Karma: 159
Posts: 2916
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

There are probably 100 different RF devices around, so it would help to know
what you're using.
Logged

Offline Offline
Edison Member
*
Karma: 58
Posts: 2078
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

RF modules with RX and TX have a chip that handles the protocol.
The very cheap RF transmitters modules can only switch the transmitter on and off.

I guess you have a very cheap 433MHz RF module.
http://www.ebay.com/sch/i.html?_odkw=433mhz&LH_BIN=1&_sop=15&_osacat=0&_from=R40&LH_PrefLoc=2&_nkw=433mhz+-antenna&_sacat=0
The output pin of the receiver module does not reflect the signal strength. You have to hack the circuit to find the signal strength (find the capacitor for the automatic gain control).

For these cheap modules, switching it on and off can not be detected by the receiver, due to the agc (automatic gain control). You have to use a software protocol. The VirtualWire is (the only) good library for that, http://www.open.com.au/mikem/arduino/VirtualWire/


« Last Edit: March 20, 2013, 02:32:27 pm by Erdin » Logged

Westbrook, CT
Offline Offline
Full Member
***
Karma: 2
Posts: 139
"Why should I bother with made-up games when there are so many real ones going on." (c) Kurt Vonnegut
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Or these:
https://www.sparkfun.com/products/10532
https://www.sparkfun.com/products/10534
Logged

Arduino Uno R3
Mac OSX Lion


Pages: [1]   Go Up
Jump to: