I am new to Arduino. I know the hardware but when it comes to coding i am having some doubts listed below:
if we have 2 or 3 operations to be performed using the arduino and so we have different set of codes. so how to merge the codes? like what to put in the setup() and what to put in the loop(). i know one time initialization stuff need to put in setup(), but when i am merging the codes then should i merge the setup() sections and loop() sections of different modules or is there a procedure for that?
we have limited number of pins in the arduino. So, if my functionality requires more number of pins so can i use the same pin for different purposes as they are anyhow separately mentioned in the codes what are doing what?
hope it is clear what my doubt is. please help.
There's no hard and fast answer to how to merge things, especially into loop(). Often with setup() it's amatter of copying both old setup()s into a new one, but with loop() it can be more complicated.
(In any case you obviously need to check for pin conflicts and duplicate uses of variable names.)
For loop(), you may have to rework the code to do what you want. If say you were to merge the well-known blink example with an example which reads a switch and controls another led, you may be screwed due to the blocking nature of blink. If you can live with (say) a second's delay until it reads your button to turn on the other led, ok. But if that delay's a problem, then you need to start from the beginning and redo the blink part to use millis() not delay().
So for a concrete answer, give it a try then ask for help if and when you get stuck.