-3

am doing multi sensor project concerning PIR,vibration,tilt angle,temp&humidity,gas sensors with LCD in Arduiono mega ...i have each sensor code,need help on programming in one program

2 Answers 2

6

You have to keep some points in your mind:

(1) You have to ensure that pins must be not conflicting with each other. If you merge all sensor codes in one code then pins must be conflict. So you have to change pin number.

(2) If all sensors have separate working then make the function for all that sensors. It will very helpful for understanding and debugging the entire code.

(3) Don't try to merge all codes same time. Add one by one and also change pin number during that.

1

am doing multi sensor project concerning PIR,vibration,tilt angle,temp&humidity,gas sensors with LCD in Arduiono mega ...i have each sensor code,need help on programming in one program

This could be considered a general question: Is it possible to merge several sketches and if so how?

The first step is to check pin conflicts: Are any of the sketches using the same pins (or resources)? If that is the case this needs to be resolved.

The next step is to check timing. Is is sufficient to run each loop() after each other or does the timing behavior also require changes.

The idea is then to simply "merge" the different setup() and loop() functions to a single setup() and loop().

In most cases, the timing behavior will leave no other choice than to rewrite the code.

There are a few tools (such as a Scheduler) that can be used but they require additional understanding of programming and nothing for the novice.

Not the answer you're looking for? Browse other questions tagged or ask your own question.