Having some noob trouble with a sketch, and an arduino uno, i'm sure anybody with more knowledge than me could help.
add me on skype, gabe.spound2
Having some noob trouble with a sketch, and an arduino uno, i'm sure anybody with more knowledge than me could help.
add me on skype, gabe.spound2
can somebody just skype with me for five minutes, im sure its a simple issue, i just don't know much
The people trying to help here are all over the world.. literally so many different time zones, we get to respond when we have a moment from our busy lives and as a principal we dont skype etc, this would lead us to not getting other things done, if you, then the next etc. and it would never be just 5mins, we have way too much experiance with these things to assume only 5mins would be enough
+ as already stated, this is a community and we help the community and expect the responses to be shared with the community. putting things here helps people see a history of the issue, how it was resolved etc. + by getting you to walk through it, you will also learn much more.
I am sorry if we seem to be a pain by making you do it this way but the other 200,000+++ folks are quite happy to conform, please understand, nothing personal, just the right way to move forward
1, 5v
2, idk what that means
3, i think im using the relay to power the led, im still not 100% how relays work, but when the switch is connected in the relay, power goes through it to the led
yeah no it still goes on and off when its powering nothing
Trying to check your program again. The LED is replaced by the relay pin, correct ?
int analogValue; // This is where we'll store our audio to digital value. More sound = higher number #define LED 2 // Set up the LED indicator boolean toggle = false; // setup a boolean function called toggle which will help us to choose which mode we're in int numberOfClaps = 0; void setup() { toggle = false; // *** Just to be sure pinMode(LED,OUTPUT); // Pin#2 should be conencted to an LED through a 300-600 ohm resistor Serial.begin(9600); // This is optional - It just helps you to calibrate sensitivity after the fact } void loop() { digitalWrite(LED,LOW); // Turn the LED off - RELAY ? delay(2000); digitalWrite(LED,HIGH); // Turn the LED on delay(2000); }
Try this first. If the relay switches every two seconds, it's a problem of logic so should check the issue in your code else it is a problem of circuit or powering. What is the power drain by the relay?
Enrico
thank you all for your elaborate suggestions but i just changed it from 5v to 3.3v and it works fine. I don't know why, but i care, why does that make any difference at all?
Well happy to read this. There are two possible options in my view. The first is that the relay - for some unknown reasons - works at a lower power to the behaviour is unpredictable. The second is that you put the wrong power. Is suggest this just because I am not there, can you make a close-up shoot where the relay is connected to the power? If you have a tester check the real power that reach the relay.
Please mark as useful or correct answer the answers / suggestions of this question thread you consider correct or if none mark the question s "assume answered" so all the other users that search something can find this question useful.
Thank you. Enrico
There are several options to try.
1. See if you can use the Blink program in the Examples to simply toggle the relay on and off. (you'll need to change the pin to something other than pin 13)
This will prove that the Arduino can indeed power it.
2. What happens when you power the relay on and off, simply by connecting it to 5v and the ground ...does your LED turn on and off.
This proves if the circuit is picking up either the relay click or the spike from the relay.
Enrico has added a longer delay which could show if that is the problem.
You have what looks like a 220 ohm resistor across A0 to ground. You need something to hold it down, but I suspect a 100K will help give a much higher Analogue voltage which may help to stop the same voltage/spike from triggering it.
Generally it's best to not share the same earth/GND path with something that generates large spikes.
Motors/Relays and large loads should have the GND wire seperate from any analogue GND.
Lastly I presume it is a 5v relay.??
Mark
Hi Gabriel,
Here is a link to a MOSFET you can use:
http://www.newark.com/vishay-siliconix/irl510pbf/n-channel-mosfet-100v-5-6a-to/dp/63J7799
John
The idea of using a transistor or a MOSFET is to have it handle a heavier current than the Arduino can handle. The arduino can put out 20 mA which is enough to switch the transistor/MOSFET on and off. The transistor can handle a larger current, enough to turn the 100 mA relay on and off and finally the relay is designed to handle even a larger current and can turn a 10 amp motor or other appliance on and off. As mcb1 points out the contacts of the relay would be on a separate circuit in any real application of this circuit. Your use of an LED tied to the analog ground is a proof of concept short cut to see if the circuit works. If all you wanted to do is turn the LED on and off you have already proved that you do not need a relay to do this. The need for a relay comes into the picture if you have bigger and more power intensive plans for the utility of the final circuit. The 3V3 supplied by the Arduino derives from the 5 volt supply through a voltage regulator. This voltage regulator produces an isolation so that any spike that might be generated by the relay coil can not get back to the A0 input as easily. While it works this way you have probably made your clap sensor a little less sensitive. Your best bet will be to put in the diode, MOSFET, and the capacitor as recommended and return your microphone circuit to the 5 volt supply.
John
BTW, Bad form to mark your own answer as the correct one, especially when you dont know why it worked?, there are many folks that have provided "Helpfull" Answers and possibly "Correct" Ones too!, please give them some credit
Now to the isue at hand
The reason it may work at 3v3 is that less power is being drawn through the relay and by inference, the Arduino output pin, with the appropriate intermediate driver it wont matter if it is 3v3 or 5V
The videos I linked in earlier should help explain that
Peter
Hi Peter,
If my interpretation of his Fritzing layout was correct the relay was getting its power from the Pin 2 of the Arduino being written HIGH. This would still be a load on the 5 volt power to the uP. Changing the power to the bread board to 3V3 only affected the microphone and LED voltage supply. I do believe it better isolated A0 from the spike that the relay coil had to be creating on the 5 volt rail.
As far as the self pat on the back I suspect he just didn't know how things work on the E14 site. A new person is hit with a lot of new stuff to deal with. Fact is he took a bit of negativity and just continued to try to supply the information requested in a positive manner. I say welcome to Gabriel and I hope he sticks around and contributes to the site.
John
Hi Peter,
If my interpretation of his Fritzing layout was correct the relay was getting its power from the Pin 2 of the Arduino being written HIGH. This would still be a load on the 5 volt power to the uP. Changing the power to the bread board to 3V3 only affected the microphone and LED voltage supply. I do believe it better isolated A0 from the spike that the relay coil had to be creating on the 5 volt rail.
As far as the self pat on the back I suspect he just didn't know how things work on the E14 site. A new person is hit with a lot of new stuff to deal with. Fact is he took a bit of negativity and just continued to try to supply the information requested in a positive manner. I say welcome to Gabriel and I hope he sticks around and contributes to the site.
John
you may well be correct there, I was only going from the email part of the description and did not look at the schamatic, either way the Arduino should not be driving a relay directly, not at any voltage