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

Thread Starter

Rob35099

Joined Sep 22, 2015
6
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.
 

GopherT

Joined Nov 23, 2012
8,009
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.
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.
 

Thread Starter

Rob35099

Joined Sep 22, 2015
6
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.
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.
 

BReeves

Joined Nov 24, 2012
410
Continuation of previous thread on closest empty bin?
Do you want to learn C or have someone write the code for you?
 
Top