1

I am trying to describe the states of all my units connected to the Raspberry Pi. I have several buttons, magnets, reed switches, LEDs, and other. This is a game and it has few phases. I want to describe states of each element for each phase and conditions to pass from one phase to another. I tried to use a state diagram, but there no states for elements. May be somebody has an example or the name of this diagram?

Example: We have 4 buttons (B1, B2, B3, B4) (Push Button Switch NO), 1 led, 1 photodiode, 1 step motor, 1 electric magnet and one contact (C1). Initial phase: - Led is switched on always but the light does not apply to the photodiode (because of the obstacle between them) - the step motor is off - the electric magnet is on and magnetizes a little door. - C1 opened

Phase 1: When buttons pushed in this combination B2, B1, B3, B1, B4 the step motor do 30 steps Then, when the obstacle between led and photodiode removed the step motor do another 30 steps Then, when C1 closed, the magnet switched off and release the little door.

18
  • 1
    Your question is unclear to me, but AFAIK, what you seem to be describing is in fact a state diagram. There are several "types" of state diagrams with different characteristics - perhaps that's what you're after? Try this Wikipedia article on state diagrams as a starter.
    – Seamus
    May 18, 2020 at 0:37
  • Hi Dzam, welcome and nice to meet you. Ah let me see. You gaming system is a bit completed. Now let me summarize. (1) Your game system has physical devices such as LED, button, magnet, reed etc. (2) You system has "phases" such as (a) game setup, (b) game playing, (c) game over, (3) Each phase has sequential/concurrent "states" such as the following: (4) State x: (i) all LED on, (ii) all button not pushed, (iii), ... (5) State y: (i) button 2 pushed, (ii) reed on, (iii) magnet demagnetized, ... You might like to comment or make counter suggestion on how to describe it. / continue, ..
    – tlfong01
    May 18, 2020 at 1:27
  • You might to wiki for a rough idea: (1) "State Diagram - Wikipedia“:en.wikipedia.org/wiki/State_diagram, (2) “UML State Machine - Wikipedia”:en.wikipedia.org/wiki/UML_state_machine. I like the UML wiki better. UML explains "actions" "trigger" "events", "behaviour" "protocol" rather than state "transitions" It is good to use a pocket calculator example states: (a) switch on calculator, (b) push button (action) trigger events (LCD display digits), (c) protocols eg. to add two numbers, (i) "x > + > y > =" or (ii) "= > x > y > +". State stuff is a hard. Go slow. Cheers.
    – tlfong01
    May 18, 2020 at 2:32
  • 1
    @tlfong01 thank you for all this useful information. I read it all and saw all examples. But still, I don't understand how to apply this to my project. I expanded the description with small example, can you help with a diagram for this specific example? Or maybe you have your own but very close to this?
    – Dzam
    May 18, 2020 at 10:28
  • 1
    @tlfong01 The question not about "how to program" this stuff. I am a programmer, for me here no problems, but how to present all these actions/states in one diagram? Or you want to start with python dictionaries and to come to the diagram?
    – Dzam
    May 18, 2020 at 12:42

0

Browse other questions tagged or ask your own question.