Smart Microgrids require innovative methods to provide decentralized multi-layer autonomous control in order to activate their elements to operate efficiently. This paper presents a coordinated control scheme based on multi-agent systems to improve the operation of a microgrid (MG) through Petri Nets (PNs). Two control layers are proposed: in the lower control layer, the switching of loads, storage devices, and distributed generation devices (DGs) are implemented; while in the upper layer, the coordinating agents consider the demand response and price dynamics in order to optimize the operation of the system. The MG includes photo-voltaic (PV) generation, wind power, and a battery storage system. Furthermore, the studied system has two MGs, connected through a DC bus linked to the grid. The coordinating system considers the operation of DGs, the charge and discharge of storage devices, the critical loads, under optimization criteria using energy prices. Switching controls for DG devices and loads are handled as discrete events and will be modeled using PNs.