2 Purpose: illustrate how you can use an array of pointers to
6 enum temperatures {TOOCOLD, TOOHOT, JUSTRIGHT};
7 enum temperatures whichAction;
13 Serial.begin(9600); // Serial link to PC
14 randomSeed(analogRead(0)); // Seed random number generator
18 static void (*funcPtr[])() = {TurnUpTemp, TurnDownTemp, PourCandy};
19 static int iterations = 0;
23 whichAction = (enum temperatures) WhichOperation(temp);
24 (*funcPtr[whichAction])();
25 if (iterations++ > 10) {
26 Serial.println("===================");
33 Purpose: decide whether to turn up heat, turn down heat, or if
34 vat is ready. Pourable candy is between 235 and 260.
36 int temp the current vat temperature
38 int 0 = temp too cold, 1 = temp too high, 2 = just right
41 int WhichOperation(int temp)
43 Serial.print("temp is ");
56 Purpose: simulate reading a vat's temperature. Values are
57 constrained between 100 and 325 degrees
66 return random(100, 325);
71 Serial.println(" in TurnUpTemp()");
76 Serial.println(" in TurnDownTemp()");
81 Serial.println(" in PourCandy()");