Show Posts
Pages: 1 2 [3] 4 5
31  Using Arduino / Programming Questions / Re: Arduino Wireless Remote -- Help Please! on: March 17, 2013, 09:24:41 pm
After installing the pull-down resistors, everything seems to check out perfect on the serial monitor. It repeats "stop" when nothing is pressed, "forward" when the forward button is pressed, and "backward" when the backwards button is pressed. Here are some updated picture of the controller:







The last thing that I seem to be having a problem with is powering everything on the board. When I have it plugged into my laptop and a 9v batter at the same time I have no problem with power. It seems that the 9v battery alone is nowhere near as powerful as it needs to be for all the LEDs and receiver and such. Do you or anyone have any suggestions as to how I could power the Arduino better?
32  Using Arduino / Programming Questions / Re: Arduino Wireless Remote -- Help Please! on: March 17, 2013, 04:12:31 pm
Could I use some 10K Ohm resistors?
33  Using Arduino / Programming Questions / Re: Arduino Wireless Remote -- Help Please! on: March 17, 2013, 02:32:06 pm
Did you install pull down resistors on the buttons? Do a search for "pull down resistor", and to use them with buttons.

Added: Wait, did you put one the receive code a way to turn off the second relay? Another thing, does the serial monitor put out "Backwards"?

No I don't think I did and Yes it does just print out "Backwards" on the serial monitor, BUT every now-and-then I will see "stop".
34  Using Arduino / Programming Questions / Re: Arduino Wireless Remote -- Help Please! on: March 17, 2013, 02:22:26 pm
**EDIT** No and yes it does say "Backwards"

Is this what I am looking for:



I can do this easy, I just want to make sure I am looking at the right thing. I am currently reading about them too, just to understand them a bit more.
35  Using Arduino / Programming Questions / Re: Arduino Wireless Remote -- Help Please! on: March 17, 2013, 01:51:51 pm
Alright playing around with the controller code for a while and this is what I have:

Code:
#include <VirtualWire.h>

int RF_TX_PIN = 2;
int Button1 = 13;      //Forward (Button 1)
int Button2 = 12;      //Backwards (Button 2)
 
void setup()
{
  Serial.begin(9600);
  Serial.println("Setup Complete");
  vw_set_tx_pin(RF_TX_PIN); // Setup transmit pin
  vw_setup(2000); // Transmission speed in bits per second.
  pinMode(Button1, INPUT);
  pinMode(Button2, INPUT);
}
 
void loop()
{
  if (digitalRead(Button1)){
  Serial.println("Forwards");
  const char *msg = "1";
  vw_send((uint8_t *)msg, strlen(msg));  // Send 'Forwards' every 50ms.
  }
  else if (digitalRead(Button2)){
  Serial.println("Backwards");
  const char *msg = "2";
  vw_send((uint8_t *)msg, strlen(msg)); // Send 'Backwards' every 50ms.
  }
  else {
  Serial.println("Stop");
  const char *msg = "0";
  vw_send((uint8_t *)msg, strlen(msg));  // Send 'Stop' every 50ms.
  }
}

Everything works, other then the fact that it is always transmitting "2" or backwards. As of right now I am stuck because I even did some research on how if-then-else statements and how they work and I don't see why this doesn't work.
36  Using Arduino / Programming Questions / Re: Arduino Wireless Remote -- Help Please! on: March 17, 2013, 11:46:01 am
Can "True" or False" act as "HIGH" or "LOW"? Or is there a different way I can re-write that statement in order for it to function as it should?
37  Using Arduino / Programming Questions / Re: Arduino Wireless Remote -- Help Please! on: March 17, 2013, 11:38:55 am
So are you saying the code is set up to return a "True" or "False" statement but in face it is not?
38  Using Arduino / Programming Questions / Re: Arduino Wireless Remote -- Help Please! on: March 17, 2013, 02:30:26 am
I don't exactly know what a Pull down resistor is. I know what a resistor is though.
39  Using Arduino / Programming Questions / Re: Arduino Wireless Remote -- Help Please! on: March 16, 2013, 11:47:59 pm
My wiring is correct. I don't even have to press anything and it will just spam "Backwards".
40  Using Arduino / Programming Questions / Re: Arduino Wireless Remote -- Help Please! on: March 16, 2013, 10:12:33 pm
Ok, adding the bracket worked. Now I need to fix the controller. Using this code:

Code:
#include <VirtualWire.h>

int RF_TX_PIN = 2;
int Button1 = 13;      //Forward (Button 1)
int Button2 = 12;      //Backwards (Button 2)
 
void setup()
{
  Serial.begin(9600);
  Serial.println("Setup Complete");
  vw_set_tx_pin(RF_TX_PIN); // Setup transmit pin
  vw_setup(2000); // Transmission speed in bits per second.
  pinMode(Button1, INPUT);
  pinMode(Button2, INPUT);
}
 
void loop()
{
  if (digitalRead(Button1)){
  Serial.println("Forwards");
  const char *msg = "1";
  vw_send((uint8_t *)msg, strlen(msg));  // Send 'Forwards' every 50ms.
  }
 
  else if(digitalRead(Button2)){
  Serial.println("Backwards");
  const char *msg = "2";
  vw_send((uint8_t *)msg, strlen(msg)); // Send 'Backwards' every 50ms.
  }
 
  else {
  Serial.println("Stop");
  const char *msg = "0";
  vw_send((uint8_t *)msg, strlen(msg));  // Send 'Stop' every 50ms.
  }
}

It just keeps sending "Backwards" over and over again.
41  Using Arduino / Programming Questions / Re: Arduino Wireless Remote -- Help Please! on: March 16, 2013, 10:09:07 pm
Ok let me try that
42  Using Arduino / Programming Questions / Re: Arduino Wireless Remote -- Help Please! on: March 16, 2013, 09:10:45 pm
When I try to do that It tells me this:

"Auto Format Canceled: Too many left curly braces."
43  Using Arduino / Programming Questions / Re: Arduino Wireless Remote -- Help Please! on: March 16, 2013, 08:47:14 pm
I tried this but it will not compile and I don't really know why:
It gives me
Code:
expected } at end of input

Code:
#include <VirtualWire.h>
 
int RF_RX_PIN = 2;
int Relay1 = 8;
int Relay2 = 9;
 
void setup()
{
  Serial.begin(9600);
  Serial.println("Serial Connection Complete");
  Serial.println();
  Serial.println("*NOTE* Currently Connected to Receiver");
  vw_set_rx_pin(RF_RX_PIN);  // Setup receive pin.
  vw_setup(2000); // Transmission speed in bits per second.
  vw_rx_start(); // Start the PLL receiver.
  pinMode(Relay1, OUTPUT);
  pinMode(Relay2, OUTPUT);
}
 
void loop()
{
  uint8_t buf[VW_MAX_MESSAGE_LEN];
  uint8_t buflen = VW_MAX_MESSAGE_LEN;
  if(vw_get_message(buf, &buflen)){
    int i;
    // Message with a good checksum received, dump HEX
    Serial.print("Got: ");
    for(i = 0; i < buflen; ++i)
    {
      Serial.print(buf[i], HEX);
      Serial.print(" ");
     
     if(buf[i] == '1') {                 // Triggers Relay 3
         digitalWrite(Relay1, HIGH);     // Turn Realy 1 on
      }
     else {
       digitalWrite(Relay1, LOW);
    }
     if(buf[i] == '2') {                 // Triggers Relay 2
       digitalWrite(Relay2, HIGH);     // Turn Realy 2 on
    }
     else {
       digitalWrite(Relay2, LOW);
     }
    delay(50);
  }
}
44  Using Arduino / Programming Questions / Re: Arduino Wireless Remote -- Help Please! on: March 16, 2013, 08:17:22 pm
Yeah thats fine. I also wanted to get a second button to work to trip a second relay. I tried this but it doesn't seem to work:

Send:
Code:
#include <VirtualWire.h>

int RF_TX_PIN = 2;
int Button1 = 13;      //Forward (Button 1)
int Button2 = 12;      //Backwards (Button 2)
 
void setup()
{
  Serial.begin(9600);
  Serial.println("Setup Complete");
  vw_set_tx_pin(RF_TX_PIN); // Setup transmit pin
  vw_setup(2000); // Transmission speed in bits per second.
  pinMode(Button1, INPUT);
  pinMode(Button2, INPUT);
}
 
void loop()
{
  if (digitalRead(Button1)){
  Serial.println("Forwards");
  const char *msg = "1";
  vw_send((uint8_t *)msg, strlen(msg));  // Send 'Forwards' every 50ms.
  }
 
  else if(digitalRead(Button2)){
  Serial.println("Backwards");
  const char *msg = "2";
  vw_send((uint8_t *)msg, strlen(msg)); // Send 'Backwards' every 50ms.
  }
 
  else {
  Serial.println("Stop");
  const char *msg = "0";
  vw_send((uint8_t *)msg, strlen(msg));  // Send 'Stop' every 50ms.
  }
}

Receive:
Code:
#include <VirtualWire.h>
 
int RF_RX_PIN = 2;
int Relay1 = 8;
int Relay2 = 9;
 
void setup()
{
  Serial.begin(9600);
  Serial.println("Serial Connection Complete");
  Serial.println();
  Serial.println("*NOTE* Currently Connected to Receiver");
  vw_set_rx_pin(RF_RX_PIN);  // Setup receive pin.
  vw_setup(2000); // Transmission speed in bits per second.
  vw_rx_start(); // Start the PLL receiver.
  pinMode(Relay1, OUTPUT);
  pinMode(Relay2, OUTPUT);
}
 
void loop()
{
  uint8_t buf[VW_MAX_MESSAGE_LEN];
  uint8_t buflen = VW_MAX_MESSAGE_LEN;
  if(vw_get_message(buf, &buflen)){
    int i;
    // Message with a good checksum received, dump HEX
    Serial.print("Got: ");
    for(i = 0; i < buflen; ++i)
    {
      Serial.print(buf[i], HEX);
      Serial.print(" ");
     
     if(buf[i] == '1') {                 // Triggers Relay 3
         digitalWrite(Relay1, HIGH);     // Turn Realy 1 on
      }
     
     if(buf[i] == '2') {                 // Triggers Relay 2
         digitalWrite(Relay2, HIGH);     // Turn Realy 2 on
      }

     else {
       digitalWrite(Relay1, LOW);
      }
    }
   
    delay(50);
  }
}
45  Using Arduino / Programming Questions / Re: Arduino Wireless Remote -- Help Please! on: March 16, 2013, 07:11:18 pm
Wow! Thanks a ton! I would have never thought of having the controller always transmit stop and then use that as a variable.
Pages: 1 2 [3] 4 5