Phonetics 5000 Home Security System User Manual


 
104
Sensaphone
®
ISACC Instruction Manual
The following is a step by step explanation of the program.
1. if (oldminute != minutes)
{
oldminute = minutes;
This checks the value of minutes to see if a minute has passed. If a minute has passed, the
value of oldminute is reset to the value of the new minute.
2. numbers[minutes] = input(1);
This line sets the value of numbers for a particular minute to the current value of input 1. For
example:
It is 3 minutes into the hour.
The value of input 1 is 72°.
Therefore:
numbers[minutes] = input(1)
is equal to:
numbers[3] = 72
3. total = 0;
This line initializes the variable total to zero.
4. for (x=0;x<60;x=x+1)
This line initializes the index variable (x) to zero, checks if it is less than 60, runs the next line,
and then increments x by one. This line creates a loop that runs the following line until x
reaches 60.
5. total = total + numbers[x];
This line of code is very important. It eliminates having 60 lines of code to get a total of all
the minute readings. The x serves to automatically read in the next value for each element in
the array. For example:
The value of x is 6 (meaning it is minute 6, incremented in step 4). The value of input 1 for
minute 6 will be read into the array and added to the total of the other 5 minutes.
The value of input 1 at minute 6 is 70. Therefore:
numbers[6] = 70
The previous total was, say, 351.
total = 351 + 70
The new total is 421.
total = 421