Blynk controlling relays on spark core

Hi, i am trying to use blynk to control relays attached to a spark core. But i don’t know how to modify the original relay.ino so i can use the blynk library. Can anyone give me a hand with this? Thanks in advance

This is the original spark core sketch for using relays:

int RELAY1 = D0;
int RELAY2 = D1;
int RELAY3 = D2;
int RELAY4 = D3;

void setup()
{
   //Initilize the relay control pins as output
   pinMode(RELAY1, OUTPUT);
   pinMode(RELAY2, OUTPUT);
   pinMode(RELAY3, OUTPUT);
   pinMode(RELAY4, OUTPUT);
   // Initialize all relays to an OFF state
   digitalWrite(RELAY1, LOW);
   digitalWrite(RELAY2, LOW);
   digitalWrite(RELAY3, LOW);
   digitalWrite(RELAY4, LOW);

   //register the Spark function
   Spark.function("relay", relayControl);
}

void loop()
{
   // This loops for ever
}

// command format r1,HIGH
int relayControl(String command)
{
  int relayState = 0;
  // parse the relay number
  int relayNumber = command.charAt(1) - '0';
  // do a sanity check
  if (relayNumber < 1 || relayNumber > 4) return -1;

  // find out the state of the relay
  if (command.substring(3,7) == "HIGH") relayState = 1;
  else if (command.substring(3,6) == "LOW") relayState = 0;
  else return -1;

  // write to the appropriate relay
  digitalWrite(relayNumber-1, relayState);
  return 1;
}

Please try running simple examples provided by our team.
Actually for controlling relays you don’t need to add custom code.
Digital operations are implemented internally.

Hello,
I used blynk own functions without writing any other code in my arduino uno and I control relays with charges.
I have a problem I can not control both directions of rotation of the motor of a blind my house with two relays. When you connect LEDs 3V relays as loads no problem, but when I connect to 250V motors relays the motor operates only in one direction when it acts a relay, with opposite (when the other acts relay ) is not working. I do not understand!
Use these relays connected to the Arduino uno:
http://www.ebay.com/itm/2-Channel-5V-Relay-Module-With-Optocoupler-For-PIC-ARM-AVR-DSP-SRD-05VDC-SL-C-/261118510987

What are you powering your Uno with? If possible use a 5v with >2amp output, I found in my plug socket that an underrated power supply caused my ESP to reset.

At first I feed the Arduino USB cable for one, then I think this could be the problem and I feed with the Arduino source of 7V. But without continued working.
I do not understand where the problem may be.