Hello Arduino community!!!
This is my first time posting on forum. So please excuse me for everything i do wrong.
I use Linux for programming my ArduinoUno. I've connected it with an 8-channel relay module and i try to control it using serial port. Every time i switch off the relay (after 2 or 3 times) the arduino resets. I'm not sure if this the right word, but technically the port name changes and i can't send data through serial port anymore and i have to change the code for renaming the port (eg from /dev/ttyACM0 to /dev/ttyACM1). I used extra diodes that i correctly soldered and, as far as i know, when i switch off the relay, an opposite current is created and i tried to prevent it from reaching arduinoUno. It didn't work...The strange thing is that Windows doesn't do that and everything works just fine. Any suggestions???
Linux version:
Distributor ID: Ubuntu
Description: Linux Lite 3.8
Release: 16.04
Codename: xenial
My code:
#define RELAY1 8
#define RELAY2 9
#define RELAY3 10
#define RELAY4 11
#define RELAY5 12
#define RELAY6 13
void setup() {
pinMode(RELAY1, OUTPUT);
pinMode(RELAY2, OUTPUT);
pinMode(RELAY3, OUTPUT);
pinMode(RELAY4, OUTPUT);
pinMode(RELAY5, OUTPUT);
pinMode(RELAY6, OUTPUT);
digitalWrite(RELAY1, HIGH);
digitalWrite(RELAY2, HIGH);
digitalWrite(RELAY3, HIGH);
digitalWrite(RELAY4, HIGH);
digitalWrite(RELAY5, HIGH);
digitalWrite(RELAY6, HIGH);
Serial.begin(9600);
}
void loop() {
if(Serial.available()){ //id data is available to read
char val = Serial.read();
if(val == 'a'){ //if r received
digitalWrite(8, LOW); //turn on red led
}
if(val == 'b'){ //if b received
digitalWrite(9, LOW); //turn on blue led
}
if(val == 'c'){ //if y received
digitalWrite(10, LOW); //turn on yellow led
}
if(val == 'd'){ //if y received
digitalWrite(11, LOW); //turn on yellow led
}
if(val == 'e'){ //if y received
digitalWrite(12, LOW); //turn on yellow led
}
if(val == 'f'){ //if y received
digitalWrite(13, LOW); //turn on yellow led
}
if(val == 'w'){
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
digitalWrite(11, HIGH);
digitalWrite(12, HIGH);
digitalWrite(13, HIGH);
}
}
}
p.s. The code is simple for testing perposes and i only use 6 relays.