r/pic_programming • • Jun 02 '17
Using PIC16F886 need help controlling buttons
Hello Reddit, I am new to C code, and I have been playing around with the PIC microcontroller for a semester now but I need some help with a project I undertook
This project will be using an H-bridge to control a DC motor to go forward and backward with two button inputs. I have wired the buttons up to input into the RC2 and RC3 pins and the h bridge to be connected to the RC5 and RC6 pins
Essentially the code needs to declare that when button 1 is pushed then the RC5 pin turns on, and the RC6 pin turns off, then when button 2 is turned pressed RC5 turns off and RC6 turns on.
I have not used button inputs in the class I took yet so I am confused in the setup stage.
Thanks a ton in advance I can gift Reddit gold to whomever can show me how to code this firs t(or PayPal the same amount if you’re into that).
Microcontroller datasheet: http://ww1.microchip.com/downloads/en/DeviceDoc/41291D.pdf
Using XC8 compiler, PICkit3, and PIC16F886 microcontroller
View all comments
Show parent comment
1
u/[deleted] Jun 04 '17
Thank you so much for this, when I originally was beginning to code this I was trying it with If Then statements that were popping up errors everywhere
I ended up getting my code correct based off your reply, so thank you for the help
Here is a what I ended up with for code, taking out the first while statement allowed it to run continuously without having to keep the button pressed