Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
// funciona enviando la información a través de Host (18F2550 & Cy2196R) #include "mbed.h" Serial RF(p13,p14); PwmOut SERVO1(p21); PwmOut SERVO2(p22); PwmOut SERVO3(p23); PwmOut SERVO4(p24); PwmOut SERVO5(p25); PwmOut SERVO6(p26); DigitalOut myled(LED1); int pos[6]={100,100,100,100,100,100}; char tramain[3]={0,0,0}; void servopos(){ if (tramain[0]=='C'){ pos[tramain[1]]=tramain[2]; myled=1; } else {myled=0;} } void Rx_Interrupt(){ tramain[0]=RF.getc(); tramain[1]=RF.getc(); tramain[2]=RF.getc(); servopos(); } int main() { RF.baud(19200); SERVO1.period_us(20000); RF.attach(&Rx_Interrupt, Serial::RxIrq); while(1){ SERVO1.pulsewidth_us(pos[0]*10); SERVO2.pulsewidth_us(pos[1]*10); } }Hi, I have made this code to control servos via RF, works well but after a while apparently reading overflows disruption to shipping though the plot correctly, after a while it works again. I know because i see the activity in "led".