– Variables

Variables are basic to making decisions: they can be thought of as the memory of values we need to decide upon, or test.  Example: Remember that ice cream you just had?  Was it very cold?  [It’s the memory of the ice cream temperature (a variable) that we must test to decide if it was too cold.]  Often it is not convenient (or even possible) to go back and directly sense the temperature with your tongue.  We hold an impression of it in memory (under the label, or name of “ice cream temperature”)  That label is a variable which can be changed based upon a new sensing (with another lick) or just remembered from the last time.  Another variable might be “flavor”.  Without the memory of the variable value, we can’t decide what action to take. [eg: lick it slowly or fast] In ‘C’ we need to ‘declare’ variables with a label or name (to hold them in the controller’s memory) before using them (eg: to test) and many times we also want to give variables an initial, or starting value (eg: ‘0’).  For KISS IDE the compilier needs to know the variable type: In robotics we mostly use a numerical variable that is either an integer (int) or a floating point (float) number.   The declaration statement uses the ‘int’ or the ‘float’ for these two types of variables.  The variable names are made up of contiguous letters (upper and lower case), the “_” character, and numbers or ‘digits’. Names cannot begin with digits.  When using a phase as the name, the “_” substitutes for a space, such as “ice_cream_temperature”, for the variable example above. In logic, variables are either ‘true’ (1) or ‘false’ (0), but in KISS C we use integers for logical tests: true is any number, false is ‘0’.  We also use variables to hold the value of buttons (real or virtual), analog sensors, motor rotation ticks, speed, etc.


previous                                                                                                                                 Next button


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s