I am requesting assistance writing code for my first project that requires integration of several boards using a few different communications methods.
I have added a picture of what I believe is a completed workable prototype. I have never completed a project of this complexity and am unsure how to meld all technologies together. I have done some extensive research gathering all data sheets along with sample codes to run each board individually.
Theory of operation:
Using Arduino IDE format on a Pro Trinket
I use 4 PWM signal wires along with a ground from a RC reciever. Each signal is generated from 4 switches on a RC radio transmitter capable of generating up to 3 PWM signals per switch.
I hook up the four PWM signals using pulseIn() function to pins A0-A3 on a Pro Trinket and assigned them ch1-ch4. (I have recorded PWM ranges that an Arduino Uno read and then displayed for each of ch1-ch4 already)
I need one channel (ch1?) to toggle a relay on/off by sending a high/low signal to a Sunflounder 5V coil relay to operate a 12VDC laser. The signal wire from the relay is hooked up to digital pin 4. Two PWMs required for this channel from RC radio.
I need one channel (ch2-ch4?) to adjust the volume level of the amp board. 3 position switch 1. Switch Low = PWM 0000 = Pro Trinket to attach ground to mute pin on amp board. Mute pin is attached to pin 3 on Pro Trinket. 2. Switch Med = PWM 1500 = Pro Trinket to send a i2c data signal to amp board to set volume at 30. 3. Switch High PWM 2500 = send i2c signal set volume at 60.
I need one channel to change between 3 different audio files on a FDPlayerMini. This is a serial UART tx/rx signal hooked up to the appropriate tx/rx pins on both Pro Trinket and DFPlayerMini. 3 Position switch with 3 PWM signals.
I need one more channel to send an another tx/rx signal from Pro Trinket to DFPlayerMini to “repeat last audio track”. Two position switch (spring loaded normally off) two PWM signals. Switch hooked to spring returns to low position after every manipulation (like a trigger). Low = no action. High = repeat last track.
I believe I have the hardware selected to accommodate these necessary tasks.
I believe the wiring and power is appropriate.
I have run individual codes testing functions to each board and confirmed audio plays and is in proper formats and file orders.
I have succeeded in reading PWM amounts from RC switches to reciever to an Arduino IDE Uno and recorded values to use for code writing.
I don’t, however, know how to write a code that works in harmony with all boards and options required. I’m not sure about what libraries to include? Not sure how to initiate multiple communications types like i2c & UART tx/rx & PWM. I’m not sure the order things should be “int” in the code.
Is there anyone out there that can assist me in competing my first whole project? I don’t mind doing the research and the leg work but I’m lost on how to construct.
Thank you very much for any help at all!!
Right now I will be looking up the actual data command strings needed to be sent for each needed function and will post as soon as I record them from the data sheets.
Any other info I can add that will be helpful?