C language help needed!

Discussion in 'Embedded Systems and Microcontrollers' started by Jnic3, Jul 1, 2010.

  1. Jnic3

    Thread Starter New Member

    Jul 1, 2010
    hi everyone,
    im using c language for my PIC 16f877A and basically im working on ultrasonic sensor... i am so confuse with the coding now as i am not so expert in programming..
    - i would like to know is it possible for me to run 2 different sensors at the same time, right after a switch is pressed? i can only succeed in running one task at the time.
    for example, the following code is functioning only for 1 task.

    - where and how am i suppose to put the "void sensor2 (void);" into this code? :confused::confused:

    void ultrasonic_sensor (void);
    void sensor2 (void);

    void main(void)
    if (!switch)


    thanks a lot!! :)
  2. debjit625

    Well-Known Member

    Apr 17, 2010
    No like this you cant run or execute code for both the sensor,i.e. the instructions or code will execute line by line so here you got two function " ultrasonic_sensor " and "sensor2" and they can only be executed one after another.Offcourse if you manage to write a single instructions that applies to both the sensor then it could work.Other way if you could use any hardware module supported in the pic for one of the sensors and write code for another sensor ,then they could run parallel (for ex.. some how using the PWM stuff for one of the sensor).

    Good Luck