7.1 Ülesanne: Nelja lambi lülitamine kahe nupuga 4
Juhtpaneeli kirjeldus
Juhtpaneelil on 3 nuppu (S1 - Start, S2 - Stop, S4 - Reset), üks võtmega lüliti (S3 - Auto/Man) ja 4 indikaatorlampi (H1, H2, H3, H4).
Ülesande püstitus
Koostada programm, mis lülitab vaheldumisi indikaatorlampisid järjekorras: Start nupu indikaatorlamp, Reset nupu indikaatorlamp, indikaatorlamp Q1, indikaatorlamp Q2, mitte üks indikaatorlamp ei ole sees, Start nupu indikaatorlamp, jne. Aktiivne lamp peab vilkuma sagedusega 1 Hz.
START nupu vajutusel lülitatakse järjekorras järgmine indikaatorlamp sisse. RESET nupu vajutusel lülitatakse järjekorras eelmine indikaatorlamp sisse.
Algselt ei tohi olla sees ükski indikaatorlamp. Korraga tohib sees olla vaid üks indikaatorlamp. Lülitamine peab olema korratav. Nuppude allhoidmisel ei tohi esineda mitme lambi valigut.
Soovitatav lugemismaterjal
Ülesande lahendamiseks tutvuda järgmiste peatükkidega.
7.1 Exercise: Switching four lights with two buttons 4
Description of the control panel
The control panel has three buttons (S1 – Start button, S2 – Stop button, S4 – Reset button), one key switch (S3 – Auto/Man (in normal state, it is on Auto)) and 4 indicator lights (lamps) (H1 – Start light, H2 – Reset light, H3 – Light Q1, H4 – Light Q2).
Description of the exercise
Write a program that switches on the lights in the order: START button light, RESET button light, light Q1, light Q2, no lights are on, START button light, etc. The active light has to flash with frequency of 1 Hz.
The next light in the order is switched on when pressing the START button. The previous light in the order is switched on when pressing the RESET button.
Initially, none of the lights are switched on. At any time, only one light can be on. The switching must be repeatable. There should be no several selection of the lights when holding the buttons.