Help Relay Code for Iphone

Hello, hope you can help me with this, im trying to make a Domotics System with an Arduino Uno, 4 Relay Module and an hm10 BT Module, im usin the Bluetuino App, so far it works for 1 relay buy y i need to make all 4 relay to work,(the only difference with the attached picture is that im using Arduino Uno not Mega) thank you in advance.

This is the actual code for 1 Relay:

#include <SoftwareSerial.h>;

SoftwareSerial bluetooth(10, 11); // RX, TX
int lightBulb = 4;
String receivedBluetoothString = “”;

void setup() {
bluetooth.begin(9600);
pinMode(lightBulb, OUTPUT);
}

void loop() {
while (bluetooth.available() > 0) {

char receivedBluetoothChar = bluetooth.read();
receivedBluetoothString += receivedBluetoothChar;

if (receivedBluetoothChar == ‘\n’) {

if (receivedBluetoothString.toInt() == 576965) {
digitalWrite(lightBulb, LOW);
}
else if (receivedBluetoothString.toInt() == 488230) {
digitalWrite(lightBulb, HIGH);
}

receivedBluetoothString = “”;
}
}
}

      if (receivedBluetoothString.toInt() == 576965) {
        digitalWrite(lightBulb, LOW);
      }
      else if (receivedBluetoothString.toInt() == 488230) {
        digitalWrite(lightBulb, HIGH);
      }

This section of code seems to toggle the state of a pin based on the value received. The pin is presumably used to drive a relay.

One clumsy way to do what you want is to repeat the code for more received values and toggle other pins.

NOTE - this is not the best way to do what you want but would be easy to try.

Where are the values such as 576965 and 488230 defined ? Presumably in whatever is being used to send them. Can they be changed to something more sensible such as 0, 1, 2, 3 etc

UKHeliBob:      if (receivedBluetoothString.toInt() == 576965) {        digitalWrite(lightBulb, LOW);      }      else if (receivedBluetoothString.toInt() == 488230) {        digitalWrite(lightBulb, HIGH);      }

This section of code seems to toggle the state of a pin based on the value received. The pin is presumably used to drive a relay.

One clumsy way to do what you want is to repeat the code for more received values and toggle other pins.

NOTE - this is not the best way to do what you want but would be easy to try.

Where are the values such as 576965 and 488230 defined ? Presumably in whatever is being used to send them. Can they be changed to something more sensible such as 0, 1, 2, 3 etc

Hi Bob Sorry for ressurecting an old thread but I got hold of a BLE HM10 module today and downloaded the Bluetuino app. It seems the codes you ask about are user defined to be whatever you want them to be and are set up in the Bluetuino app for the action you want to execute. So the ones above are in the predefined 'Turn on light bulb' and 'Turn off light bulb' demos supplied with the Bluetuino app and they can be readily and easily changed. The Arduino digital pin of course, is selected in the Sketch. So... to the OP - simply do as Bob suggested but choose different codes and make sure you add those codes to custom 'Add basic remote code' within Bluetuino. Hope this helps, allbeit several months old...

Sorry for bringing this thread back up, but I am in desperate need of the bluetuino app .ipa iphone file. I had this on my old iphone and just recently got a new one. For some reason the app didn't save when I did my phone backup. I am running a few devices with it and it works really well. It's a shame it isn't available on itunes any more.