I am making a model RCS system for a university project. The TLDR is that an arduino nano controls 4 solenoid valves via a 12v relay, and the valves release pressurized air from 4 nozzles placed at the top of the rocket, 2 along the x axis and 2 along the y axis, thus altering/correcting its orientation. The switching of the valves is controlled from the arduino using an IMU (gyro). Additionally, there is an arm switch, that starts the sequence, and there is a buzzer , LED, and 4 servos that deploy some legs when the arm switch is switched to ON.
Here is the very messy and crude electrical diagram. The connections will be made on a breadboard, except for the relay and valves, that draw a lot of power from a different power bus (you will noitce that I also used some placeholder modules). I connected the servos on PWM pins and matched the IMU pins to the standard use analog pins used on most codes for that module. Can you spot any mistakes?
Unfortunately my arduino knowledge is lackluster, so I have come here for aid.
Here are my questions:
Can I just connect the signal wires from the arduino digital pins and a GND And 5v wire from the arduino to the valve relay (12V 2A power source powers the /valves) and expect it to work normally? Or is there a problem with the voltage dfference between the arduino and the relay/valves? If so, how is it adressed?
Can I use power from USB to power the rest of the electronics through the arduino (5v)?
Can I put the led circuit within the buzzer circuit, so they both operate at the same time?
And most importantly: The IMU I will be using is the mp6050 on the gy-521 module. I want to use the onboard processor to improve the quality of the inputs.
Can someone help me with the code? I need a library and code segment that gives the gyro inputs, as well as some variables for fine tuning and error correcting. These values will be used to switch on the valves on when the lean of the rocket on any of the 2 axis is more than 1 deg. , and close them when the value get below 1 again. Also I need help with making a code that starts deploying the legs , activates the buzzer and led for a brief time and starts the valve when I activate the arm switch, and retracts the legs and activates the led and buzzer briefly and stops the valve part of the program, until it gets switched on again.
I know that this is much to ask, but I thought that I would rather gather it in one big post than posting lots of smaller ones.
Thanks in advance,