Arduino code
byte relayPin[4] = {2,7,8,10};
//D2 -> RELAY1
//D7 -> RELAY2
//D8 -> RELAY3
//D10 -> RELAY4
void setup(){
for(int i = 0; i < 4; i++) pinMode(relayPin[i],OUTPUT);
}
// an sample to switch the 4 relays
void loop(){
int i;
for(i = 0; i < 4; i++) digitalWrite(relayPin[i],HIGH);
delay(1000);
for(i = 0; i < 4; i++) digitalWrite(relayPin[i],LOW);
delay(1000);
}
I was written below c# code for my arduino code.But the C# code was getting error.
The c# was not connected to my arduino hardware. How to solve this issue.
Please help me to solve this problem.
C# code
private void button1_Click(object sender, EventArgs e)
{
serialPort1.PortName = "COM25";
serialPort1.BaudRate = 9600;
serialPort1.Open();
Byte[] data = new byte[4];
data[0] = 2;
data[1] = 3;
data[2] = 8;
data[3] = 10;
serialPort1.Write(data, 0, serialPort1.BytesToWrite);
}