New to code.

I love reading others codes and seeing how parts of it can help me. But how do i add separate sketches together. such as adding the sweep sketch with the ping sketch

in the main part do i call functions?

voide servoPos()
for (pos = 45: //like that? is there a video tutorial on blending different actions. after i get the servo to sweep, and the ping to take readings. I'll next need to make decisions on how close something the ping sees gets, befor i take action, like stop, turn go

any help would be appreciated. if theres a tutorial out there, id like to check it out. it doesnt have to be about what im doing, I just want to see how they use multiple actions work together.
Thanks, Freedb

I too learned a lot at first just by reading some of the many example sketches in the Arduino files/example menu. Once you understand the individual functions then it's a matter of planning how you will combine them into one sketch. The key is to understand the basic structure of a sketch. The Arduino defines two sections, the void setup() function and the void loop() functions. You place all the things that only need to be defined or executed once into the setup function. Everything else goes into the loop function. The loop function never ends, if and when it gets to the last statement of the loop it just jumps back to the first statement of the loop.

That help at all?

Lefty

Another usefull method is to build various parts of a sketch as functions.

A function is a blok of program code that can be called from another part of your program.

So if one of the sketches you want to combine contains a "block of code" you want to use, it's probably a good idea to turn that block of code into a function that you can call from your programs loop function.

This can be a concept that is hard to understand for programming beginners, but if you try it out by defining a very simple project with a function that does something very simple then you will get it.

if someone could show me an example code. Are the functions set up like this --
void pingread()
{
ping read code here;
}

then call it with

pingread(xx,stuff);

pingread(xx,stuff);

No you would call that function with pingread();
Passing things numbers you would need to declare the number type in the function.
void pingread(int var){
// ping read code
}

call with:-
pingread(6);
or pingread(My_variable);

see:-
http://www.arduino.cc/en/Reference/FunctionDeclaration

thanks a bunch. its coming along nicely , learning the codeing quickly