Adafruit Industries, Essential service and business: NYC – Executive Order 202.6 - Read more. Accepting essential orders - here's how.
0

sound effect player connecting to arduino mega
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Re: sound effect player connecting to arduino mega

by adafruit_support_bill on Sat Nov 30, 2019 7:36 am

Yes. The PN2222 are only good for up to about 500mA. I'd go with one of these: https://www.adafruit.com/product/355
MOSFETs are more efficient that BJTs like the Pn2222. And there is no need for the resistor in the circuit. You can drive the gate directly from a digital pin on your Mega.

adafruit_support_bill
 
Posts: 76650
Joined: Sat Feb 07, 2009 10:11 am

Re: sound effect player connecting to arduino mega

by roadshark on Sat Nov 30, 2019 8:54 am

Had a look at the LED tutorial. Have I got this correct. Pin 1 goes to the PWM pin on the MEGA. (GATE) Pin 2 goes to the motor and Pin 3 goes to the GND on the mega and power supply

roadshark
 
Posts: 585
Joined: Sun Nov 29, 2015 5:53 am

Re: sound effect player connecting to arduino mega

by adafruit_support_bill on Sat Nov 30, 2019 9:20 am

That is correct.

adafruit_support_bill
 
Posts: 76650
Joined: Sat Feb 07, 2009 10:11 am

Re: sound effect player connecting to arduino mega

by roadshark on Sun Dec 01, 2019 7:21 am

I plan to run the 1.2" Display, one servo, and the SDA, SCL, (with a pull up resistors) From the 5v pin on the mega via a circuit board. To keep the voltage constant especially when the servo kicks in I thought a capacitor on the circuit board would be a good idea. I have got these (PID 2192) 220uf 16V in my last order. If one is not enough can I place these in parallel?

Is this capacitor enough insurance just for one servo?

roadshark
 
Posts: 585
Joined: Sun Nov 29, 2015 5:53 am

Re: sound effect player connecting to arduino mega

by adafruit_support_bill on Sun Dec 01, 2019 7:48 am

220uF should be adequate for most small to medium size servos. Some of the bigger high-torque models can be pretty disruptive and might do better with more capacitance. You can just wire more in parallel if needed.

If I recall correctly, the 5v pin on the Mega is limited to about 500mA via a polyfuse. To avoid that limitation - and to provide further isolation for your servo power - I'd branch from your main supply and run power and ground directly to the servo, then connect a signal and ground wire from the servo back to the Mega.

adafruit_support_bill
 
Posts: 76650
Joined: Sat Feb 07, 2009 10:11 am

Re: sound effect player connecting to arduino mega

by roadshark on Sun Dec 01, 2019 5:12 pm

As always Bill.......a wealth of knowledge. THX :)

roadshark
 
Posts: 585
Joined: Sun Nov 29, 2015 5:53 am

Re: sound effect player connecting to arduino mega

by roadshark on Sat Dec 07, 2019 7:20 am

Hi Bill,
int motorPin = 12;
pinMode (motorPin,OUTPUT);

Should this code turn the DC motor I have attached to pin 12 off? (Remember I connecting the motor via a mofset.)
Code: Select all | TOGGLE FULL SIZE
 analogWrite(motorPin, 0);

At the moment as soon as I connect the power the motor begins. If this is the case then something must be askew in my wiring. :(

Also on the mega on there are two 5 volt pins on one end of all the digital I/O pins Start at 22) and on the other end there are two GND PINS. Am I able to use these to power the display or should I use the 5volt and GND pins on the Power side??
Last edited by roadshark on Sat Dec 07, 2019 7:46 am, edited 1 time in total.

roadshark
 
Posts: 585
Joined: Sun Nov 29, 2015 5:53 am

Re: sound effect player connecting to arduino mega

by adafruit_support_bill on Sat Dec 07, 2019 7:35 am

Writing a 0 should turn the motor off. If you post some pics we'll check the wiring.

And you can take the 5v from any of the 5v pins. Whichever is most convenient.

adafruit_support_bill
 
Posts: 76650
Joined: Sat Feb 07, 2009 10:11 am

Re: sound effect player connecting to arduino mega

by roadshark on Sat Dec 07, 2019 7:53 am

Sorry for my ignorance here Bill but if I am using one power supply all GND will lead back to the negative on the power supply?

roadshark
 
Posts: 585
Joined: Sun Nov 29, 2015 5:53 am

Re: sound effect player connecting to arduino mega

by adafruit_support_bill on Sat Dec 07, 2019 11:28 am

That is correct. And even if you are using multiple supplies to power different parts of your circuit, you should connect all the grounds together.

adafruit_support_bill
 
Posts: 76650
Joined: Sat Feb 07, 2009 10:11 am

Re: sound effect player connecting to arduino mega

by roadshark on Sat Dec 14, 2019 1:46 am

Hi Bill,
Still having issues with the motor. On start everything works fine. The score light sequence starts and finishes. As soon as I press the start button, the sound effect plays, the starting light sequence starts and finishes then the servo releases the ball for the player then resets to stop the balls in the game. The motor should now turn on to turn the monster head however what happens is that the mega resets itself and we go back to the starting lighting sequence. I am assuming that soon as the code sends the pwm and the gate opens there is a short? If I disconnect the motor the game moves into the correct sequence and ball sensors work etc (some time a ball does not activate a sensor but this is a problem for later on :( ).
Here is the code and I have attached the photo of the wiring.
Code: Select all | TOGGLE FULL SIZE
int motorPin = 12;
Serial.println("In case 3 game 2");
      analogWrite(motorPin, 190);

      matrix.print(gameScore, DEC);
      matrix.writeDisplay();
      if (digitalRead (47) == LOW) {

        Serial.println("Reset Button Pressed!");

        state = 0;
        break;
      }
Attachments
wiring of motor 1.png
wiring of motor 1.png (750.86 KiB) Viewed 91 times

roadshark
 
Posts: 585
Joined: Sun Nov 29, 2015 5:53 am

Re: sound effect player connecting to arduino mega

by adafruit_support_bill on Sat Dec 14, 2019 7:21 am

Is the motor powered by the same supply as the Mega? The starting current for the motor might be causing the voltage to sag and reset the Mega. A big capacitor between power and ground on your circuit board might help with that.

adafruit_support_bill
 
Posts: 76650
Joined: Sat Feb 07, 2009 10:11 am

Re: sound effect player connecting to arduino mega

by roadshark on Sat Dec 14, 2019 9:27 am

Is the motor powered by the same supply as the Mega?


Yes it is Bill,
I have recently purchased some of these 220uF 16V Electrolytic Capacitors. Are these big enough or do I need to put a few together?

roadshark
 
Posts: 585
Joined: Sun Nov 29, 2015 5:53 am

Re: sound effect player connecting to arduino mega

by adafruit_support_bill on Sat Dec 14, 2019 9:39 am

Hard to say. Startup current for a motor is essentially the same as the stall current. And that can be several times higher than the normal running current.
It usually drops off quickly once the motor starts moving, but if you have a significant load attached, it will take longer to get going. If it is a sizable motor and/or load, you may need a few of those caps to handle the startup current.

Another test - just to verify that your motor circuit is working properly: Disconnect the blue wire from pin 12, connect it to +5v and verify that the motor runs.

adafruit_support_bill
 
Posts: 76650
Joined: Sat Feb 07, 2009 10:11 am

Re: sound effect player connecting to arduino mega

by roadshark on Sat Dec 14, 2019 8:42 pm

just to verify that your motor circuit is working properly: Disconnect the blue wire from pin 12, connect it to +5v and verify that the motor runs.


As soon as I touch the blue wire to +5V on the mega the mega shuts down and restarts continuously. If I touch the blue wire to the +5 feed from the step down converter which powers the sound effects player and the itsy the same happens.
I disconnected the circuit board form the mega and tried it as a stand along. I connected the red wire to the +9V from the power supply and the black wire to the negative side of the power supply. Nothing happens. l then touch the blue wire to the positive side of the power supply and nothing happens. Should this open the gate?
I by passed the circuit with the negative wire connecting it to the motor and the motor turns fine? Have I got the correct MOSFET n channel 30v/60a http://adafru.it/355

roadshark
 
Posts: 585
Joined: Sun Nov 29, 2015 5:53 am

Please be positive and constructive with your questions and comments.