I am using the MTS-51 microcomputer trainer and I have to implement a project which contains the stepper motor(unipoler stepper motor) and the keypad which are included onboard.
The project might be simple but something is amiss with my thought propably so I would like any advice if is possible. The objectvies are the following. 1. When key "1" from keypad is pressed the motor performs one step clockwise. 2. When key "2" from keypad is pressed the motor performs one step counter clockwise. (The motor performs a step everytime you press one of the keys. For example if you spam any of the keys it will step for each time you pressed the key.)
My code was the following:
#include <reg51.h>
void main() { for(;;) { if(P1=0x00)//counter clockwise step { P2=0x33; P2=0x66; delay();//I have made my own delay function for space's sake I won't include it here } if(P2=0x01) { P2=0x33; P2=0x99; delay(); } } } My main idea was when one of the conditions where met I would change the value of P1 with a value assignment so it won't meet the condition again so when I would press one of the buttons(0 or 1) it would meet again the condition and the step would be performed. But I failed to achieve this thought.