Pages: [1]   Go Down
Author Topic: RF transmitter and reciver  (Read 442 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
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?

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);

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);

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

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

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.
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,

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

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

Or these:

Arduino Uno R3
Teensy 3.0
Mac OSX Yosemite

Pages: [1]   Go Up
Jump to: