hfdh

Dependencies:   Encoder MODSERIAL mbed

Fork of BO by Thomas Plaisier

Committer:
lubbermans
Date:
Mon Jun 30 12:42:21 2014 +0000
Revision:
6:7ff223862008
Parent:
5:31120c4c08f0
hoi

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Socrates 0:095ff84c3ee9 1 #include "mbed.h"
Socrates 0:095ff84c3ee9 2 #include "encoder.h"
Socrates 2:9dc7b40286d1 3 #include "MODSERIAL.h"
Socrates 0:095ff84c3ee9 4
lubbermans 6:7ff223862008 5 PwmOut pwmA(PTA1);
lubbermans 6:7ff223862008 6 PwmOut pwmB(PTD2);
lubbermans 6:7ff223862008 7 DigitalOut dirA(PTD3);
lubbermans 6:7ff223862008 8 DigitalOut dirB(PTD1);
lubbermans 6:7ff223862008 9 Encoder motor1(PTC3,PTB23);
lubbermans 6:7ff223862008 10 MODSERIAL pc(USBTX,USBRX);
lubbermans 6:7ff223862008 11 Ticker timer;
lubbermans 6:7ff223862008 12 Ticker scripttimer;
Socrates 0:095ff84c3ee9 13
lubbermans 6:7ff223862008 14 int x ;
lubbermans 6:7ff223862008 15 volatile bool scriptflag;
lubbermans 6:7ff223862008 16
lubbermans 6:7ff223862008 17 void looper()
Socrates 0:095ff84c3ee9 18 {
lubbermans 6:7ff223862008 19 pc.printf("%i\n", x);
lubbermans 6:7ff223862008 20
Socrates 0:095ff84c3ee9 21 }
lubbermans 6:7ff223862008 22 void scripter()
Socrates 2:9dc7b40286d1 23 {
lubbermans 6:7ff223862008 24 scriptflag=true;
Socrates 0:095ff84c3ee9 25 }
Socrates 0:095ff84c3ee9 26 int main()
Socrates 0:095ff84c3ee9 27 {
lubbermans 6:7ff223862008 28 pwmA.period(1.0/20000.0);
lubbermans 6:7ff223862008 29 pwmB.period(1.0/20000.0);
Socrates 1:95dd5c626960 30 pc.baud(115200);
lubbermans 6:7ff223862008 31 pc.printf("hoi");
lubbermans 6:7ff223862008 32 scripttimer.attach(scripter,1.0/5000.0);
lubbermans 6:7ff223862008 33 timer.attach(looper, 0.1);
lubbermans 6:7ff223862008 34 while(1) {
Socrates 1:95dd5c626960 35
lubbermans 6:7ff223862008 36 while(scriptflag==false) {
lubbermans 6:7ff223862008 37 }
lubbermans 6:7ff223862008 38 scriptflag=false;
lubbermans 6:7ff223862008 39
Socrates 0:095ff84c3ee9 40
lubbermans 6:7ff223862008 41 x=motor1.getPosition();
Socrates 5:31120c4c08f0 42
lubbermans 6:7ff223862008 43 dirA=1;
lubbermans 6:7ff223862008 44 pwmA=0.5;
lubbermans 6:7ff223862008 45
Socrates 5:31120c4c08f0 46
Socrates 0:095ff84c3ee9 47 }
Socrates 0:095ff84c3ee9 48 }