Hello, forums!
I am newer to the world of Arduino, but I have a general understanding (I think :P). I am working on a project where I need to be able to upload my code to my ATMega328p through an audio jack (stereo) and it's socket through Serial.
I'm not sure if there would be a way to simply connect my jack to Rx & Tx, or if I need to buy a USB to TTL converter and then connect it to that (and if that is the case, how would I go about doing so with the jack as it has the tip, ring, and sleeve).
I currently have my Mega soldered to a perfboard and at the moment I have been uploading my code through an Uno directly onto my Mega through D10-13.
Any advice helps, and if I left out anything important, I will glady provide that information
First, lets straighten out your nomenclature. The jack is the female part of the connector. The plug is what you are calling a jack. The plug is the male part of the connector.
The quick answer is no you do not want to try that. When you insert the plug into the jack, You are SHORTING the connections as the mate together and not until the plug is almost entirely inserted are the correct connections made. Your plug likely has three connections, called "tip", "ring" and ground. As you insert the plug the tip will be shorted to the ground of the jack, then the ring will be shorted and finally all is ok when fully inserted.
My first though is; how are you powering the board? If not through the "audio" plug/jack you can do what you wish.
You would need to make ground the normal "audio" ground. As @Paul_KD7HB stated the connections will short out when the plug is inserted and you can't assume its a transient. So you will have to put some resistors in series with the programming pins to protect them from the short. I would think 250 ohms or so should do it.
I am powering my board through a portable charger that is attached to my case.
What I was hoping to accomplish was instead of having a USB port on the side of my case is to have the 1/4" female jack instead (for aesthetic reasons). So while my board is off, I plug in my male plug, turn on my board, upload my code, turn off my board, and then remove it once upload completes.
I know my plug has the tip and ring, which I think I can connect to Rx & Tx, but I have no way of sending a signal to Reset (I was thinking of adding an additional switch onto my board to click once my code compiles, just before the upload, but I'd prefer to avoid that if possible (or find another workaround)).
EDIT: Forgot to address, would I still need to add the resistors along side my programming pins even if I do not have the board on while inserting my plug?
You might be able to figure a way to reset the board when the plug is inserted, using the built in switch on the jack. But the board still needs to be powered.
1/4" female jack
Why 1/4 inch can't you use a mini like on your phone? (I forget the official name).
To upload via serial, you will have to reset the board; this will require an additional wire in your connector from the TTL-to-USB converter's DTR signal to the reset pin of the Arduino.
Would resetting the board programmically work? For example, if I were to connect D5 directly to Reset and then just use digitalWrite(5, LOW); to trigger it? If so, then I might just be able to get this to work the way I'd like. I don't know if that would be considered good practice though, lol.
I'm building a recreation of an industry-standard film slate and trying to do so as accurately as possible, which requires a 1/4" among other things to get as close as I can.
In theory yes; in practice maybe not as the reset 'pulse' might be too short. But you can easily test that
If you go that way, note that you first have to enable the internal pull-up (either pinMode(5, INPUT_PULLUP) or digitalWrite(5, HIGH)) before setting the pin to output; else you will immediately reset the board at the moment that you make the pin LOW).
Can you explain why you need to upload code to the arduino during operation? Typically, you upload code before even closing the case, which would render the "need" for the audio jack upload moot.
Couple of obvious questions why do you need to upload different programs on a regular basis ?
Why aren’t you programming the Mega at the moment via usb ?
I am using an RTC and, from what I know, I'm only able to update the time on it by reuploading the code with a function to set the time. I figured since I already had that function I would just stick with it. I'll do some more Googling right now to see if there is another way to set the time without having to reupload the code, but I haven't seen anything prior.
EDIT: I originally was using a converter but the one I had was faulty so I returned it, then while I was searching for another one, I did the trick where you use an Uno to upload to the Mega and then just stuck with it.