Show Posts
Pages: [1]
1  Topics / Device Hacking / Using an old PSU to power motors on: February 05, 2011, 11:50:59 pm
I'm a noob at electronics and would it be safe if I used an old 150w ATE PSU to power some 12v stepper motors? I see its outputs at 12v 4.6A.
2  Forum 2005-2010 (read only) / Syntax & Programs / Re: Virtual Wire with simple led on/off on: January 04, 2011, 08:44:28 pm
it finally works!

I lowered the rate from 2000 to 1200
 so for future reference:

transmitter:
Code:
#include <VirtualWire.h>
#undef int
#undef abs
#undef double
#undef float
#undef round

void setup()
{
  Serial.begin(9600);
  Serial.println("Activated");
  vw_set_ptt_inverted(true);
  vw_set_tx_pin(12);
  vw_setup(1200);
}

void loop()
{
  if (Serial.available() > 0)
  {
    char message = Serial.read();
    vw_send((uint8_t *)&message, strlen(&message));
    vw_wait_tx();
  }
}

receiver:
Code:
#include <VirtualWire.h>  
#undef int
#undef abs
#undef double
#undef float
#undef round

void setup()
{
  vw_set_ptt_inverted(true);
  vw_set_rx_pin(12);
  vw_setup(1200);
  vw_rx_start();
  pinMode(13, OUTPUT);
}

void loop()
{
  uint8_t buf[VW_MAX_MESSAGE_LEN];
  uint8_t buflen = VW_MAX_MESSAGE_LEN;
  
  if (vw_get_message(buf, &buflen))
  {
    if (buf[0] == 'a') {
      digitalWrite(13, HIGH);
    }
    if (buf[0] == 'b') {
      digitalWrite(13, LOW);
    }
  }
}

thanks all for your help!
3  Forum 2005-2010 (read only) / Syntax & Programs / Re: Virtual Wire with simple led on/off on: December 29, 2010, 04:55:00 pm
ok, Thanks. I'll try that.
4  Forum 2005-2010 (read only) / Syntax & Programs / Re: Virtual Wire with simple led on/off on: December 29, 2010, 04:28:27 pm
Ok, I tried:

Code:
void loop()
{
  uint8_t buf[VW_MAX_MESSAGE_LEN];
  uint8_t buflen = VW_MAX_MESSAGE_LEN;
  
  if (vw_get_message(buf, &buflen))
  {
    if (buf[0] == 'a') {
      digitalWrite(13, HIGH);
    }
    if (buf[0] == 'b') {
      digitalWrite(13, LOW);
    }
  }
}

It dosen't seem to work.
5  Forum 2005-2010 (read only) / Syntax & Programs / Virtual Wire with simple led on/off on: December 29, 2010, 02:13:36 pm
Hello, I am trying to control an arduino using virtual wire and I'm having trouble with my code. My transmitter is connected to the computer and I'm trying to send things like: 'a' or 'b' through the serial. The second arduino should receive these and turn an led on and off. What could be the problem?


Transmitter:
Code:
#include <VirtualWire.h>
#undef int
#undef abs
#undef double
#undef float
#undef round

void setup()
{
  Serial.begin(9600);
  Serial.println("Activated");
  vw_set_ptt_inverted(true);
  vw_setup(2000);
  vw_set_tx_pin(13);
}

void loop()
{
  if (Serial.available() > 0)
  {
    char message = Serial.read();
    vw_send((uint8_t *)&message, 1);
    vw_wait_tx();
  }
}


Receiver:
Code:
#include <VirtualWire.h>  
#undef int
#undef abs
#undef double
#undef float
#undef round

void setup()
{
  vw_set_ptt_inverted(true);
  vw_setup(2000);
  vw_set_rx_pin(12);
  vw_rx_start();
  pinMode(13, OUTPUT);
}

void loop()
{
  uint8_t buf[VW_MAX_MESSAGE_LEN];
  uint8_t buflen = VW_MAX_MESSAGE_LEN;
  
  if (vw_get_message(buf, &buflen))
  {
    if (buf[buflen] == 'a') {
      digitalWrite(13, HIGH);
    }
    if (buf[buflen] == 'b') {
      digitalWrite(13, LOW);
    }
  }
}
Pages: [1]