help with c code (should be easy for the novice!)

Discussion in 'The Projects Forum' started by Rob35099, Oct 14, 2015.

  1. Rob35099

    Thread Starter New Member

    Sep 22, 2015
    6
    0
    Hi I need help to write code for the following:
    I want to press + release button 1 (to start everything), then.....

    if button 2 is not pressed down then command XXXXX is done
    if button 2 is pressed down then we assess button 3:

    if button 3 is not pressed down then command YYYYYY is done
    if button 3 is pressed down then we assess button 4: if button 4 is pressed down then we light an LED: if button 4 is not pressed down then command ZZZZZ is done


    I want to use pull down resistors so that button press = logic 1. Buttons 2,3,4 will have weights sitting ontop of them. Any ideas? Thankyou!

    PS My C code knowledge is limited - i've tried to improve but need help here.
     
  2. GopherT

    AAC Fanatic!

    Nov 23, 2012
    5,982
    3,718
    You will need to tell us what type of microcontroller you plan to use and which pins those pull-down resistors are connected to on the Microcontroller. Also, what XXXXX, YYYYYY and ZZZZZ are so we can show you how to output commands to initiate those.
     
  3. Rob35099

    Thread Starter New Member

    Sep 22, 2015
    6
    0
    Ooops - I'm rather tired and hence missed this info. Also my title is wrong - I'm the novice!!

    Ok,

    I'm using a PIC 16F877A

    The switches (1,2,3,4) are pins B6,B4,B2,B0 respectively. LED is connected to pin D6.

    Commands XXXXX, YYYYY, ZZZZZZ are just high/low commands in various sequences to various DC motors and stepper motors.

    Hope this helps and thank you for replying to me.
     
  4. BReeves

    Member

    Nov 24, 2012
    412
    64
    Continuation of previous thread on closest empty bin?
    Do you want to learn C or have someone write the code for you?
     
Loading...