.
Dependencies: RadioIn Servo mbed
Revision 0:b59cb9ef5b5b, committed 2013-04-13
- Comitter:
- lfsantarelli
- Date:
- Sat Apr 13 01:00:26 2013 +0000
- Commit message:
- .
Changed in this revision
diff -r 000000000000 -r b59cb9ef5b5b Config.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Config.h Sat Apr 13 01:00:26 2013 +0000 @@ -0,0 +1,51 @@ +//Pino de Entrada do Switch +#define pswitch p24 + +//Pinos das saidas analogicas para SaberTooth +#define psaber1 p26 +#define psaber2 p25 + +//Pinos dos sensores de linha +#define plFL p29 +#define plFR p30 +#define plRL p28 +#define plRR p27 + +//Pinos dos sensores de distancia +#define pd1 p20 +#define pd2 p19 +#define pd3 p18 +#define pd4 p17 +#define pd5 p16 + +//Comunicacao serial +Serial pc(USBTX,USBRX); + +//Saida dos LEDs +DigitalOut led1(LED1); +DigitalOut led2(LED2); +DigitalOut led3(LED3); +DigitalOut led4(LED4); + +//Entrada do Switch +DigitalIn sSWITCH(pswitch); + +//Entradas dos sensores de linha +DigitalIn slFL(plFL); +DigitalIn slFR(plFR); +DigitalIn slRL(plRL); +DigitalIn slRR(plRR); + +//Entradas dos sensores de distancia +DigitalIn sd1(pd1); +DigitalIn sd2(pd2); +DigitalIn sd3(pd3); +DigitalIn sd4(pd4); +DigitalIn sd5(pd5); + +//Saidas analogicas para SaberTooth +PwmOut saber1(psaber1); +PwmOut saber2(psaber2); + +//Entrada de radio +RadioIn radio; \ No newline at end of file
diff -r 000000000000 -r b59cb9ef5b5b RadioIn.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/RadioIn.lib Sat Apr 13 01:00:26 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/lfsantarelli/code/RadioIn/#0c22ced44247
diff -r 000000000000 -r b59cb9ef5b5b Servo.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Servo.lib Sat Apr 13 01:00:26 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/simon/code/Servo/#36b69a7ced07
diff -r 000000000000 -r b59cb9ef5b5b main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Apr 13 01:00:26 2013 +0000 @@ -0,0 +1,43 @@ +#include "Servo.h" +#include "mbed.h" +#include "RadioIn.h" +#include "Config.h" + +void Drive(float m_esq, float m_dir){ // Valores de -1 a 1 em cada motor +saber1.write((m_esq/2)+0.5); +saber2.write((m_esq/2)+0.5); +} + +void DriveRC(){ + float trim=0; // Trim para casar o 0 da sabertooth com o PWM do Mbed + radio.Update(); + saber1.write((radio.chan1+1)/2+trim); + saber2.write((radio.chan2+1)/2+trim); +} + + +float ReadRadio(int chan){ // Retorna o valor do canal entre -1 e 1 +radio.Update(); +if (chan==1){return radio.chan1;} +if (chan==2){return radio.chan2;} +if (chan==3){return radio.chan3;} +else return 0; +} + + +// Melhor usar o V-Tail Mixer e fazer o mix via hardware +void DriveMixedRC(){ + radio.Update(); + saber1.write(((radio.chan1+radio.chan2)+1)/2); + saber2.write(((radio.chan1-radio.chan2)+1)/2); +} + +int main() +{ +saber1.period_us(5); +saber2.period_us(5); +radio.Init(); +while(1){ + DriveMixedRC(); + } +} \ No newline at end of file
diff -r 000000000000 -r b59cb9ef5b5b mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Apr 13 01:00:26 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/5e5da4a5990b \ No newline at end of file