10 years, 8 months ago.  This question has been closed. Reason: Solved

Communication problem

Hello, I tried to send commend to my microcontroller to control my Moto controller and it’s didn’t respond to me. I need to send command LA5555 (move forward rpm) Here is my code

int main() { pc.printf("Motor Controller Initialized \n\r ");

char instr[8]; int index;

while (1) { if (pc.readable()) give me to run loop constantly { char c;

index = 0;

while (pc.readable()) { c = pc.getc();

instr[index++] = c;

pc.printf("My command '%c'\n\r", c); }

if(instr[0] == 'L' && instr[1] == 'A') { IN1 = 1; (p24) IN2 = 0; (p25) MOD = 0; (p26) STB = 1; (p23) PWM.period(1.0/100000); PWM.write(duty);

long num = atoi(&instr[2]); convert number from memory allocated in 2 pc.printf("I got '%i'\n\r", num); print integer } } } }