Thread: Trying to understand logic before to write code

  1. #1
    Registered User
    Join Date
    Feb 2022
    Posts
    73

    Trying to understand logic before to write code

    Let's say a microcontroller is connected to two green lights, two red lights, two motors, six switch buttons and a sensor

    Light_One_RED
    Light_Two_RED

    Light_One_GREEN
    Light_Two_GREEN

    Motor_One
    Motor_Two

    Motor_One_Start Button
    Motor_Two_Start Button
    Motor_One_Stop_Button
    Motor_Two_Stop_Button

    Reset_Button
    Pass_Button

    Object_Sensor

    In the beginning, light one red and light two red both remain on while light one green and light two green both remain off. Also both motors stay off.

    If the sensor detects an object, the light one
    RED should be turn OFF while the light one Green should be turn On.

    Motor one does not turn on until the sensor detects the object

    If the sensor is faulty or not working, the motor one can also be start / stop manually by pressing Motor_One_Start Button and Motor_One_Stop_Button


    Motor one can be controlled via button or controlled via sensor, I don't understand the how sequence will work to control motor one in the system?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    Basically, you need to design one of these first.
    Finite-state machine - Wikipedia
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help me understand the logic of the code?
    By Orcus in forum C Programming
    Replies: 4
    Last Post: 06-16-2017, 01:22 AM
  2. Replies: 5
    Last Post: 07-16-2016, 04:14 AM
  3. What gets printed? Trying to understand the logic.
    By Joie Moie in forum C Programming
    Replies: 1
    Last Post: 05-02-2013, 07:30 PM
  4. Recursive function, trying to understand the logic.
    By csharp100 in forum C Programming
    Replies: 7
    Last Post: 11-16-2010, 11:38 AM
  5. I don't want to write a code I don't understand ..!!
    By bchaib in forum C Programming
    Replies: 28
    Last Post: 12-19-2007, 04:29 AM

Tags for this Thread