Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of Robocode by
Diff: source/main.cpp
- Revision:
- 25:08ee4525155b
- Parent:
- 24:6c2fec64f890
- Child:
- 27:df11ab63cda4
--- a/source/main.cpp Sat Mar 04 15:04:14 2017 +0000
+++ b/source/main.cpp Sun Mar 05 12:18:04 2017 +0000
@@ -4,7 +4,7 @@
* Version 0.0.1
* PES2 Gruppe 1
**/
-
+/*
#include "mbed.h"
#include "pathfinding.h"
#include "time.h"
@@ -14,8 +14,8 @@
//static double time_counter = 0.0f;
//static double deltatime = 0.0f;
-//InterruptIn EncoderLeftA(PB_6);
-//InterruptIn EncoderLeftB(PB_7);
+InterruptIn EncoderLeftA(PB_6);
+InterruptIn EncoderLeftB(PB_7);
InterruptIn EncoderRightA(PA_6);
InterruptIn EncoderRightB(PC_7);
@@ -33,7 +33,7 @@
//indicator leds arround robot
DigitalOut leds[] = { PC_8, PC_6, PB_12, PA_7, PC_0, PC_9 };
-DigitalOut led(LED1); // Board LED
+
@@ -43,37 +43,53 @@
int main()
{
- __enable_irq();
+ //__enable_irq();
- // EncoderLeftA.rise(&highPulseDetectedL);
- //EncoderLeftB.rise(&highPulseDetectedL);
- //EncoderRightA.rise(&highPulseDetectedR); // wird erkannt
- //EncoderRightB.rise(&highPulseDetectedR); // wird erkannt
+ EncoderLeftA.rise(&highPulseDetectedL);
+ EncoderLeftB.rise(&highPulseDetectedL);
+ EncoderRightA.rise(&highPulseDetectedR); // wird erkannt
+ EncoderRightB.rise(&highPulseDetectedR); // wird erkannt
move_init();
while(1) {
- //sync_movement(false,true);
- if(encoder) {
- led = 1;
- } else {
- led = 0;
- }
+ sync_movement(false,true);
+
}
+}
+
+*/
+
+#include "mbed.h"
+
+InterruptIn EncoderLeftA(PB_6);
+InterruptIn EncoderLeftB(PB_7);
+InterruptIn EncoderRightA(PA_6);
+InterruptIn EncoderRightB(PC_7);
+
+int EncoderCounterLeft = 0;
+int EncoderCounterRight = 0;
- /* while(1){
- if(status == 1){
- led = 0;
- wait(0.5);
- status = 0;
- }else{
- led = 1;
- timer0 = 0.0f;
- pathfinding();
- status = 1;
- }
- }*/
+
+void highPulseDetectedL()
+{
+ EncoderCounterLeft += 1;
+}
+
+void highPulseDetectedR()
+{
+ EncoderCounterRight += 1;
}
+int main()
+{
+ EncoderLeftA.rise(&highPulseDetectedL); // wird nicht erkannt
+ EncoderLeftB.rise(&highPulseDetectedL); // wird nicht erkannt
+ EncoderRightA.rise(&highPulseDetectedR); // wird erkannt
+ EncoderRightB.rise(&highPulseDetectedR); // wird erkannt
+ while(1) {
+ printf("left: %d || right: %d\r\n",EncoderCounterLeft,EncoderCounterRight);
+ }
+}
