## 3 Results  
### Case Study: Control of Laboratory Discrete-Event System  
For verification of the developed software tool and discrete-event systems control method it was necessary to design a laboratory model of such a system. A fire alarm model was built. The scheme can be seen in Figure 7.  
The fire alarm model consists of an active buzzer, photoresistor, three resistors and an NPN transistor. The NPN transistor is mandatory for active buzzer connection. The LED of Arduino in pin 13 is also used. A photoresistor was used instead of a smoke sensor to simplify the experiment.  
Figure 6: PN2 ARDUINO—Analog input.  
Figure 7: The scheme of laboratory model of fire alarm.  
Next, the behavior of the system must be defined. When the photoresistor detects an excessive lighting (experimentally determined as an input value greater than 799 on the analog pin of Arduino Uno which resolution is from 0 to 1023) the intermittent tone of the buzzer is turned on. This tone alternates with LED lighting. When the value on the analog pin drops below 800, the sound and light effects stop. This is repeated cyclically.  
Initial marking of modeled timed Petri Net interpreted for control (or sometimes known as timed interpreted Petri net) in PN2 ARDUINO is shown in Figure 8.  
Places of the Petri net (Figures 8-10) correspond to the following states:  
\(p_{1}\)--alarm does not detect fire  
\(p_{2}\) and \(p_{3}\)--alarm is active (fire was detected)  
Transitions of Petri net (Figures 8-10) correspond with the following actions/events:  
\(t_{1}\)--alarm is turned on  
\(t_{2}\)--alarm makes a noise  
\(t_{3}\)--signal light blinks  
\(t_{4}\) and \(t_{5}\)--alarm is turned off  
The token in place \(p_{1}\) corresponds to the state when the fire alarm is not activated because the photoresistor has not detected the light intensity threshold.  
When a value greater than 799 is detected on the analog pin of Arduino, the transition \(t_{1}\) is fired. This transition is associated with Arduino component _Analog Input_ where the range of input values is set. The transition is enabled depending on this range.  
Figure 8: Petri Net for fire alarm (initial marking).  
Figure 9: Petri Net for fire alarm (\(t_{1}\) is fired).  
In Figure 9, the token is in the place \(p_{2}\). Transition \(t_{2}\) is associated with Arduino component _Digital Output_ (pin 8 in this case) where the buzzer is connected. This transition has also associated the function of a time delay (2 s) which means that the transition firing (and buzzer sound effect) lasts for 2 s.  
In Figure 10, the token is in the place \(p_{3}\) (Figure 10). Transition \(t_{3}\) is associated with Arduino component _Digital Output_ (pin 13 in this case) where the build-in LED is connected. The time delay is set to 1 s, i.e., the LED diode is turned on for 1 s.  
This process is repeated cyclically, and stops when the value on the analog pin drops under 800. Then the transition \(t_{4}\) or \(t_{5}\) is fired and the token moves to the place \(p_{1}\) when the fire alarm does not detect the fire.  
The reachability graph for described Petri net is shown in Figure 11.  
We can conclude that the ability of discrete-event control with PN2 ARDUINO was successfully verified and can be generalized for other applications.