coding for a transmitter,receiver pair

I'm coding for an Arduino Nano to run two servos.

A momentary button w/transmitter and the receiver attached to it's pin on the nano.

when the button is pressed the nano runs first one servo, then another.

I tried high/low state, but got nothing.

How do you code for a button w/ transmitter?

How do you code for a button w/ transmitter?

What kind of transmitter? Don't you think that might be important? And, but the button back on the shirt. Use a damned switch!

The transmitter is a Seeedstudio 433MHz Low Cost transmitter/receiver pair.

The transmitter is a Seeedstudio 433MHz Low Cost transmitter/receiver pair.

So, what is the problem? Didn't SeedStudio provide sample code? If not, there must be something like 342344541815815181 examples that Google could find. After all,everyone and his brother thinks those useless things are usable.

Below are some discussions concerning your type of tx/rx that might be of use.

https://www.google.com/search?as_q=433MHz&as_epq=&as_oq=&as_eq=&as_nlo=&as_nhi=&lr=&cr=&as_qdr=all&as_sitesearch=http%3A%2F%2Fforum.arduino.cc%2Findex&as_occt=any&safe=images&tbs=&as_filetype=&as_rights=&gws_rd=ssl

Thanks, I have been searching through google. Have not yet found a way to code a momentary button switch equipped with a transmitter, but continue to search.

For those who have no real help to offer…thanks for the attempt at sarcasm, good entertainment.

bbishop: For those who have no real help to offer...thanks for the attempt at sarcasm, good entertainment.

On the other hand, if you bothered to post your code we might have some chance of having something useful to say.

If you don't provide input you can 't expect much in the way of output.

...R

#include <Servo.h>

const int BLACK_BUTTON_PIN = 0;        
const int UP_DOWN_MOTOR_PIN = 14;       
const int FORWARD_BACK_MOTOR_PIN = 13;  
  
Servo upDownMotorServo; 
Servo forwardBackMotorServo;   

int blackButtonState = 0; 
int upDownMotorPosition = 0; 
int forwardBackMotorPosition = 0;  

void setup() {  
  

pinMode(BLACK_BUTTON_PIN, INPUT);  
upDownMotorServo.attach(UP_DOWN_MOTOR_PIN);
forwardBackMotorServo.attach(FORWARD_BACK_MOTOR_PIN);
}
void loop() {

blackButtonState = digitalRead(BLACK_BUTTON_PIN);
  if (blackButtonState == HIGH)  
   {if (upDownMotorPosition < 180)    
    {upDownMotorPosition = 180;
      upDownMotorServo.write(upDownMotorPosition);
       delay(25);    
}  }}

When I upload code, does the previously uploaded code get completely overwritten?

Thank you for your code.
Just for information the code tags must be in square brackets [ code] and [ /code] - but without the spaces

I don’t understand what you are trying to acheive with this piece of code as all it seems to do is move the servo to 180 deg and leave it there.

void loop() {

    blackButtonState = digitalRead(BLACK_BUTTON_PIN);
    if (blackButtonState == HIGH) 
    {
        if (upDownMotorPosition < 180)   
        {
            upDownMotorPosition = 180;
            upDownMotorServo.write(upDownMotorPosition);
            delay(25);   
        }  
    }
}

You may also note that I have refornatted it for easier reading.

It is not a good idea to use pins 0 or 1 as they are used for Serial communication with the PC and that is useful so you can print debug messages.

It is also better not to use Pin13 as it is connected to the onboard LED - which can cause problems in some circumstances.

…R

Momentary contact pushbutton transmitters and matching receivers can be bought here: https://www.adafruit.com/product/1095

The code is trying to achieve exactly what you suspect. Since there is only the one pin that is explicitly for a receiver, that's what I used. If, however that presents a problem to the goal of receiving a signal from the transmitter on the switch, I could change to another digital pin - but only if.

I would like more information on how using pin 13 can be problematic to my own purpose. I used it because the servos are physically attached to a motor shield, which is attached to the Nano by the corresponding pins. On the motor shield, the servos are connected to pins 13 and 14 which is why I used 13 and 14 on the Nano.

Thanks for the attention, right now nothing happens when the button is pressed.

You refer to a TxRx but don't appear to use it in the code. Please give more detail as to where it comes into the project.

Weedpharma

I explain in the first post...and showing it in the code is my question.

blackButtonState = digitalRead(BLACK_BUTTON_PIN);

Does not give any indication of using the wireless module.

The wireless module does not have a black button.

This module requires data to be sent, it is not a press button on Tx and change state on Rx.

You need to set it up as having an MCU read the button on the send end then cause a piece of data to be sent to the other end. When the Rx receives the data, it becomes the black button on or off.

If you simply want a press button to operate a relay closure, you have bought the wrong device. Refer to earlier post with link to that type of device.

Weedpharma

@bbishop: Please edit your post, select the code, and put it between [code][/code] tags.

You can do that by hitting the “Code” button above the posting area (It looks like a scroll with < > inside it).

How to use this forum

bbishop:
The code is trying to achieve exactly what you suspect. Since there is only the one pin that is explicitly for a receiver, that’s what I used.

What have you in mind when you say “explicitly for a receiver” ?

If you mean that Pin0 is the Rx pin - that is only relevant if the Arduino is receiving serial data.
Your code suggests you just want to detect whether the pin is high or low so any of the I/O pins will do and you can leave pins 0 and 1 free for communication with the PC.

Of course it is entirely possible that your transmitter/receiver uses serial data, and if so digitalRead() is not the answer.

Please post a link to the datasheet for the transmitter/reciever you are using.

…R

bbishop: When I upload code, does the previously uploaded code get completely overwritten?

Yes. What else would happen to it?

I tried high/low state, but got nothing.

Please post your schematic.

http://www.seeedstudio.com/depot/433Mhz-RF-link-kit-p-127.html

Is the device pair.

Weedpharma

Thank you for posting the link...but how do I code for it?