Loop verbage - words that make things happen ?

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
mjpcarbon
 
Posts: 436
Joined: Fri Nov 29, 2013 8:57 pm

Loop verbage - words that make things happen ?

Post by mjpcarbon »

First off I am having a blast, I have ordered more boards sensors etc and having good success with projects and modifying sketches to do what I want them to do but I have questions.
For example in the Beginner Book there are "loop" terms like "oneAfterAnother, motorOnthenOff etc..
I am a bit lost as to where these come from, are they made up by the great minds that make the example sketches ? Is there a glossary I have not come across yet.
I basically understand digitalread,write pins and those type funtions but want to learn more, also confusing is void why was that programming word chosen.
Also come to find out that capitalization means a lot,how do you know when and where to apply

I know I am babbling a bit and asking questions that may not make sense

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Loop verbage - words that make things happen ?

Post by adafruit_support_bill »

For example in the Beginner Book there are "loop" terms like "oneAfterAnother, motorOnthenOff etc.
What book are you referring to? Can you provide a link?

User avatar
mjpcarbon
 
Posts: 436
Joined: Fri Nov 29, 2013 8:57 pm

Re: Loop verbage - words that make things happen ?

Post by mjpcarbon »

Sorry I was referring to the booklet that came with the Beginner kit "Experimenters Guide"
circ-02 oneafteranothernoloop oneatatime

circ-03 motoronthenoff motoracceleration

circ-06 playnote playtone

where do these terms come from?

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Loop verbage - words that make things happen ?

Post by adafruit_support_bill »

where do these terms come from?
Those terms are being defined by the example code. For example, motorOnThenOff() is defined as follows:

This is a 'comment header' describing what the following lines of code do. Everything between "/*" and "*/" is a comment.

Code: Select all

/*
 * motorOnThenOff() - turns motor on then off 
 * (notice this code is identical to the code we used for
 * the blinking LED)
 */
This line defines the function "motorOnThenOff()". Everything between the matching "{" and "}" is part of the function. You can call this function anywhere in your program.

Code: Select all

void motorOnThenOff(){
These lines are the 'body' of the function. Whenever you call "motorOnThenOff()", these lines of code are executed.

Code: Select all

  int onTime = 2500;  //the number of milliseconds for the motor to turn on for
  int offTime = 1000; //the number of milliseconds for the motor to turn off for
  
  digitalWrite(motorPin, HIGH); // turns the motor On
  delay(onTime);                // waits for onTime milliseconds
  digitalWrite(motorPin, LOW);  // turns the motor Off
  delay(offTime);               // waits for offTime milliseconds
}

User avatar
mjpcarbon
 
Posts: 436
Joined: Fri Nov 29, 2013 8:57 pm

Re: Loop verbage - words that make things happen ?

Post by mjpcarbon »

Bill in the line void motorOnThenOff what has real meaning the word motor or the OnThenOff ?

Would void motor be the same ? Is the OnThenOff really needed or more of a description of what is going to happen and does the Uppercase matter?

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Loop verbage - words that make things happen ?

Post by adafruit_support_bill »

in the line void motorOnThenOff what has real meaning the word motor or the OnThenOff ?
Neither. You could call it "xyzzy" if you wanted. motorOnThemOff is just a more descriptive name for what it does. Similarly, the upper/lower case conventions have no real meaning either. You just have to be consistent. If you define it to be "sillyThing()", then you have to spell it exactly the same whenever you call it. If you try to call "sillything()" or SillyThing()" you will get a compile error.

User avatar
mjpcarbon
 
Posts: 436
Joined: Fri Nov 29, 2013 8:57 pm

Re: Loop verbage - words that make things happen ?

Post by mjpcarbon »

Perfect !
Thank you

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”