Hello everyone. I am currently trying to get a program to run using a transmitter and a receiver using an arduino. The receiver is not currently listening for the signal from the transmitter. I will attatch the code I have written below. Can someone please help me figure out the issue. If not, I would love a reference to a basic code for a receiver and transmitter. I am new to arduino so any help I can get is greatly appreciated.
Why are you using analogRead here instead of digitalRead?
data=analogRead(rfReceivePin);
The transmitter is doing digitalWrite, the receiver should be using digitalRead.
How are the Functions getting pulled in?
Are you using Rf modules? Or just wired together directly?
If wired, do you have Gnd connected also?
If Rf, we need to know what kind of module; and the code as written is too simplistic.
I took your advice and changed the program to digitalRead and connected the receiver to digital pin 3 instead of Analog 0. The receiver program is still running without listening for the transmitter though. Why is this?
/* Receiver Program
It's awesome!
*/ #define pin1 8//these are the Arduino pins that we use to activate coils 1-4 of the stepper motor #define pin2 9 #define pin3 10 #define pin4 11 #define delaytime 8 #define rfReceivePin 4
unsigned int data = 0; // variable used to store received data
void loop() {
data=digitalRead(rfReceivePin); //listen for data on Analog pin 0
if(data=HIGH){
int numberOfSteps = 64;
step_OFF(); //turning all coils off
while(numberOfSteps>0){
forward(); //going forward
numberOfSteps -- ;//counting down the number of steps
}
delay(2000);
step_OFF(); //turning all coils off
numberOfSteps = 64;
while(numberOfSteps>0){
backward(); //going backward
numberOfSteps -- ;//counting down the number of steps
}
delay(2000);
Serial.println(data);
}
if(data=LOW){
Serial.println(data);
}
}