Initial Commit

Dependencies:   mbed HC05 QEI MODSERIAL SWSPI mbed-rtos

Committer:
Throwbot
Date:
Sun Oct 05 15:27:32 2014 +0000
Revision:
0:43331220df0d
Child:
1:1da89c13dfa1
Ebot Working full code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Throwbot 0:43331220df0d 1 #include "QEI.h"
Throwbot 0:43331220df0d 2 #include "mbed.h"
Throwbot 0:43331220df0d 3 #include "robot.h"
Throwbot 0:43331220df0d 4 #include "rtos.h"
Throwbot 0:43331220df0d 5 #define ulrL PTD6
Throwbot 0:43331220df0d 6 #define ulR PTD5
Throwbot 0:43331220df0d 7 #define ulF PTD1
Throwbot 0:43331220df0d 8 #define ulrR PTC2
Throwbot 0:43331220df0d 9 #define ulB PTC1
Throwbot 0:43331220df0d 10 #define ulL PTC0
Throwbot 0:43331220df0d 11 AnalogIn uL(ulL);
Throwbot 0:43331220df0d 12 AnalogIn uF(ulF);
Throwbot 0:43331220df0d 13 AnalogIn uR(ulR);
Throwbot 0:43331220df0d 14 AnalogIn urR(ulrR);
Throwbot 0:43331220df0d 15 AnalogIn urL(ulrL);
Throwbot 0:43331220df0d 16 char c;
Throwbot 0:43331220df0d 17 int main() {
Throwbot 0:43331220df0d 18 initRobot();
Throwbot 0:43331220df0d 19 Thread buzzer_th(pl_buzzer, NULL, osPriorityNormal, 2048, NULL);
Throwbot 0:43331220df0d 20 motor_control(lMotor*m_speed,rMotor*m_speed);
Throwbot 0:43331220df0d 21 while(1){
Throwbot 0:43331220df0d 22 //bt.printf("Pulses is: Revolutions is: \r\n");
Throwbot 0:43331220df0d 23 //bt.lock();
Throwbot 0:43331220df0d 24 // bt.printf("LDR1_%lf;LDR2_%lf;Pulses is: %i Revolutions is: %i Pulses is: %i ultrasonic: , \r\n",ldrread1(),ldrread2(), left.getPulses(), left.getRevolutions(),right.getPulses());//, uL.read()*5*102.54*2.54);
Throwbot 0:43331220df0d 25 //bt.printf("s;LDR1_%lf;LDR2_%lf;Pulses is: %i ; %i:s\n\r",ldrread1(),ldrread2(),wheel.getPulses(), wheel.getRevolutions());
Throwbot 0:43331220df0d 26 // motor_control(lMotor*m_speed,rMotor*m_speed);
Throwbot 0:43331220df0d 27 //bt.unlock();
Throwbot 0:43331220df0d 28 if(bt.readable()){
Throwbot 0:43331220df0d 29 c = bt.getc();
Throwbot 0:43331220df0d 30 if(c=='?')
Throwbot 0:43331220df0d 31 {
Throwbot 0:43331220df0d 32 bt.lock();
Throwbot 0:43331220df0d 33 bt.printf("EBOTDEMO\n");
Throwbot 0:43331220df0d 34 bt.unlock();
Throwbot 0:43331220df0d 35 }
Throwbot 0:43331220df0d 36 /* int number = (c-'0');
Throwbot 0:43331220df0d 37 stdio_mutex.lock();
Throwbot 0:43331220df0d 38 freq = number;
Throwbot 0:43331220df0d 39 stdio_mutex.unlock();
Throwbot 0:43331220df0d 40 motor_control(0,0);
Throwbot 0:43331220df0d 41
Throwbot 0:43331220df0d 42 */}
Throwbot 0:43331220df0d 43 if(ldrread1()>0.6)
Throwbot 0:43331220df0d 44 {
Throwbot 0:43331220df0d 45 //pl_buzzer();
Throwbot 0:43331220df0d 46
Throwbot 0:43331220df0d 47 }
Throwbot 0:43331220df0d 48 if(ldrread2()>0.6)
Throwbot 0:43331220df0d 49 {
Throwbot 0:43331220df0d 50 Led_on();
Throwbot 0:43331220df0d 51 }
Throwbot 0:43331220df0d 52 else
Throwbot 0:43331220df0d 53 {
Throwbot 0:43331220df0d 54 Led_off();
Throwbot 0:43331220df0d 55 }
Throwbot 0:43331220df0d 56 //Thread::wait(1);
Throwbot 0:43331220df0d 57 Thread::wait(50);
Throwbot 0:43331220df0d 58
Throwbot 0:43331220df0d 59 }
Throwbot 0:43331220df0d 60 }