Recent Changes - Search:

Introduction to Microcontroller Programming

About PICmicro Chips

Clocking Your PICmicro Devices

E-Blocks

Flowcode Step By Step

PICmicro Projects

Labs

Set up the Calculation

<^< Create the Variables | Course Index | Loop Properties >^>

  1. Double-click on the Calculation icon to open the Properties dialogue box.
  1. Change the Display name to "New total".
  2. Tell the Calculation icon what it is supposed to calculate by typing the following equation in the Calculations window:
TOTAL = TOTAL + SHEEP
We are going to simulate the light beam using a single push switch on Port A bit 0 - the switch marked 'SW0' on the switch board.
  • The Input Properties are set up to store whatever number appears on port A in the variable called 'SHEEP'.
  • When the switch is not pressed, the number on Port A is 0, and this is stored in the variable 'SHEEP'.
  • When we press the switch, the number 1 is inputted via Port A, and stored in the variable 'SHEEP'.
(As we are using only one switch, the biggest number we can produce on Port A is 1.)
When the Calculation icon is activated, the number stored in the variable 'SHEEP' is added to the 'TOTAL' variable. When a sheep breaks the light beam, in other words, then 'TOTAL' is increased by 1. When no sheep is present, 'TOTAL' remains unchanged.
  1. Then click on the OK button, to close the dialogue box.

<^< Create the Variables | Course index | Loop Properties >^>

Print - Search - Login

Page last modified on May 03, 2013, at 04:04 PM