Hi! I'm a freshman and don't have much experience in circuitry.
Basically I'm just trying to get a solenoid connected to an arduino to work, but it just, isn't? I had like three other TA's try to figure out what's happening as well but none of us could, even after switching out various components. Here's the circuitry in Tinkercad (used a DC motor as a stand in as a solenoid, which to my understanding should be the same thing circuitry wise), which weirdly enough works just fine.
const int solenoidPin = 8; // The Arduino pin connected to the transistor/MOSFET
void setup() {
pinMode(solenoidPin, OUTPUT); // Set the pin as an output
}
void loop() {
digitalWrite(solenoidPin, HIGH); // Turn the solenoid on
delay(1000); // Wait for 1 second
digitalWrite(solenoidPin, LOW); // Turn the solenoid off
delay(1000); // Wait for 1 second
}
And I did wire everything exactly as is in Tinkercad, so I'm just not sure. Could it be something to do with the transistor I'm using (I looked up the code it has online and the pins are all in the right place)?? I would really appreciate the help, if this post needs anymore information just let me know, I just started learning a few weeks ago so I'm not sure what's needed to troubleshoot. Thank you so much!!
Use you DVM, digital volt meter to see what voltage is on the pin when it is on and when it is off. Bet the motor/solenoid draws enough current that the 9 volt battery voltage drops to near zero.
Ok, will do! But basically what you're saying is that the battery I'm using is not enough?? If so, is there any way to counteract this besides just getting a bigger battery? Sorry if this is an obvious question, and thank you for the help
If you are in fact using a 9V battery, you're lucky. It likely will start to wilt long before the full second you're driving the solenoid for (the solenoid that you're powering from the 5V pin on the Arduino, which is a driven by a tiny little linear regulator - that doesn't have a heat sink).
Looking at a typical 5-6V solenoid on Adafruit, it needs 800mA.
The linear regulator on the Arduino might be good half that. A quarter of that would be safer.
Someone will not doubt be along short (if they haven't been already) to tell you that an Arduino is not a power supply.
And a 9V battery is designed to supply low currents for a long time. Not to supply high currents for even short times.
Had you used, say, a 9V adapter or a 5V power bank (i.e. something capable of delivering some significant current), the linear regulator on your Arduino would likely have already popped. It's supposed to go into thermal shutdown before it gets close to doing that, but Murphy has a mean sense of humour.
Oh, that's kinda scary. Ok, I will definitely look into trying to get a more powerful battery then, and I'll update this post tomorrow if it worked! Thank you for the insight
Did you skip over the part where I mentioned that a more powerful power source would likely destroy the 5V regulator on the Arduino the way you have things wired up?
I'm gonna be fully honest I had no idea what that meant...I just learned what a breadboard was like a few weeks ago, so I don't understand a lot of terms, sorry!!
So I need a more powerful battery, but if I do the Arduino will break because of my wiring? If that's the case, then how would I go about powering the Arduino/components with the battery? Is there another thing I need? Or is it just a matter of switching some wires around? Thank you for pointing that out again
Begin with ONE component and get it and the program working properly. Then add a second component and change your program to use both components they way you want them to work. Never do a project of any type by wiring all the components together and writing a program handle all the components, and then begin to test and debug your program.
Just the way you have always learned in school. One step at a time. Your testing as you go is just the same as you have exams at the end of each classroom segment.