Arduino freezes when using power on my relay board
hey everyone,
i'm working on project use midi notes switch 8 old lamps using arduino uno. i've build case 8 wall sockets linked relay board arduino. use hairless midi serial bridge send midi notes via usb arduino. serial data used send digital outputs relay board. board has 8 relays can switched 5 volts.
this works , fast until put power on sockets.
then, after 5~10 seconds arduino freezes. relay shield stays in it's current state , indication lights serial communication stop flashing. hairless serial midi bridge still show activity. when there isn't 220 volts going through relays works great. relay board i'm using had 8 led's indication , respond intended without power switched on.
i tried make simple schematic clarify setup. arduino powered via usb. tried powering arduino additional adapter of 5v , 500ma didn't make difference.
i'm confused why happens , hope can me. i'm novice might doing stupid here (highly probable).
materials:
this code running on arduino. it's based on code i've found processing serial midi.
thanks in advance!
- jwktje
i'm working on project use midi notes switch 8 old lamps using arduino uno. i've build case 8 wall sockets linked relay board arduino. use hairless midi serial bridge send midi notes via usb arduino. serial data used send digital outputs relay board. board has 8 relays can switched 5 volts.
this works , fast until put power on sockets.
then, after 5~10 seconds arduino freezes. relay shield stays in it's current state , indication lights serial communication stop flashing. hairless serial midi bridge still show activity. when there isn't 220 volts going through relays works great. relay board i'm using had 8 led's indication , respond intended without power switched on.
i tried make simple schematic clarify setup. arduino powered via usb. tried powering arduino additional adapter of 5v , 500ma didn't make difference.
i'm confused why happens , hope can me. i'm novice might doing stupid here (highly probable).
materials:
- arduino uno revision 3
- relay board 8 relays switched 5 volt. capable of handling 10a. bought here: https://iprototype.nl/products/components/buttons-switches/relay-board-8-channels-5v
- 8 normal wallsockets powered 220 volts
- 8 light bulbs e27 fitting
this code running on arduino. it's based on code i've found processing serial midi.
code: [select]
#include <digitalwritefast.h>
byte incomingbyte=0;
byte notebyte=0;
byte velocitybyte=0;
byte statusbuffer=0;
byte note_on = 144;
byte note_off = 128;
boolean arp_triggernext=false;
boolean firstbyte;
void midi_poll(){
if (serial.available() > 0) {
{
// read incoming byte:
incomingbyte = serial.read();
if (incomingbyte>247) {
// midi clock stuff done
switch (incomingbyte){
}
}
else if (incomingbyte>240) {
statusbuffer = 0;
//sysex stuff done here
}
else if (incomingbyte>127) {
statusbuffer = incomingbyte;
firstbyte = true;
notebyte = 0;
velocitybyte = 0;
}
else if (statusbuffer!=0) {
if (firstbyte == true) {
// must first byte
notebyte = incomingbyte;
firstbyte = false;
}
else {
// must second byte then
velocitybyte = incomingbyte;
//process message here
if (statusbuffer == note_on && velocitybyte != 0) {
switch (notebyte) {
case 60:
digitalwritefast2(2, high);
break;
case 61:
digitalwritefast2(3, high);
break;
case 62:
digitalwritefast2(4, high);
break;
case 63:
digitalwritefast2(5, high);
break;
case 64:
digitalwritefast2(6, high);
break;
case 65:
digitalwritefast2(7, high);
break;
case 66:
digitalwritefast2(8, high);
break;
case 67:
digitalwritefast2(9, high);
break;
}
}
else if (statusbuffer == note_off || (statusbuffer == note_on && velocitybyte == 0)) {
switch (notebyte){
case 60:
digitalwritefast2(2, low);
break;
case 61:
digitalwritefast2(3, low);
break;
case 62:
digitalwritefast2(4, low);
break;
case 63:
digitalwritefast2(5, low);
break;
case 64:
digitalwritefast2(6, low);
break;
case 65:
digitalwritefast2(7, low);
break;
case 66:
digitalwritefast2(8, low);
break;
case 67:
digitalwritefast2(9, low);
break;
}
}
//now clear them next note
notebyte = 0;
velocitybyte = 0;
firstbyte = true;
}
}
} while (serial.available() > 0);
}
}
void setup() {
pinmode(2, output);
pinmode(3, output);
pinmode(4, output);
pinmode(5, output);
pinmode(6, output);
pinmode(7, output);
pinmode(8, output);
pinmode(9, output);
serial.begin(9600);
}
void loop() {
midi_poll();
}
thanks in advance!
- jwktje
i/o pins can deliver max 40ma (you need more drive reay coil)
use transistors (and resitores) ... present already?
supply 5v other source arduino
use transistors (and resitores) ... present already?
supply 5v other source arduino
Arduino Forum > Using Arduino > Project Guidance > Arduino freezes when using power on my relay board
arduino
Comments
Post a Comment