I am trying to make an LED fade and a motor vibrate at the same time. I got them working separately, but when I try to combine them, the script doesn’t work. Any help would be appreciate it.
chamaz:
No, … I want to be sure if the problem came from code or came from the circuit.
That’s exactly the reason why you would need to have a multimeter! Comparing the actual voltages you get against the voltages and currents that you expect to get based on your program and circuit design. Using a multimeter you can check if your program really does pull a pin high, even without connected motor. Then, if you connect a motor or something to it, measure how much current it causes to flow, or what voltage is dropped across it.
To troubleshoot an electrical problem you should always have a multimeter. You might try to smell, taste, touch or hear the current flowing. But that’s usually not pleasant for the senses, or practical. Get the right tool for the job. (Ok, I’ve heard recently that Sparkfun is having supply issues with these kind of things, but surely you can get a cheap one somewhere else. Anything is better than nothing.)
Looks like you supply power to the motor, directly from an output pin, and through a resistor. What sort of value is that? 1000 Ohm? This is where a multimeter would come in real handy, measuring the voltages at each connection point. And using it to measure the current that actually goes through it as you try to power it. Then consider those values if that is enough to make the motor run or led burn. Do it, you really learn from it.
It looks like you’ve got the resistor in series w/the motor and not the LED. That’s not right, you want it the other way (R in series w/the LED). I can’t tell what Arduino is in the pic, and so can’t even guess at the pins used. Can you provide a simple schematic ? Recall that it’s not wise to use pins 0 or 1 as a lot of Arduinos use these pins to communicate to the PC.