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: HCSR
Dependents: BERTL_ButtonLeds Bertl_Arbeit FollowLine SerialPC ... more
Fork of ur_Bertl by
Revision 13:3ce84646fd74, committed 2015-04-27
- Comitter:
- bulmecisco
- Date:
- Mon Apr 27 13:13:45 2015 +0000
- Parent:
- 12:cedc088eaf05
- Child:
- 15:43d6a7e6e64a
- Commit message:
- Bertl version 3.0 updated
Changed in this revision
--- a/config.h Sun Apr 26 20:04:47 2015 +0000 +++ b/config.h Mon Apr 27 13:13:45 2015 +0000 @@ -1,6 +1,6 @@ /*! \file config.h \brief A Documented file. -* name: config.h Version: 1.1 \n +* name: config.h Version: 3.0 \n * author: PE HTL BULME \n * email: pe@bulme.at \n * description: @@ -16,8 +16,9 @@ /*! \def DEBUG \brief Turns debugging infos off (0) and on (3) which are send to serial pc.uart */ #define DEBUG 0 -//#define FRONTBUTTON /**< Error shutoff if Bertl moves against a wall*/ -#define HCSR /**< if ultrsonic is installed*/ +//#define FRONTBUTTON /**< Error shutoff if Bertl moves against a wall*/ +#define HCSR /**< if ultrsonic is installed*/ +#define MOTORENC P1_12 /**< P1_12: left encoder P1_13: rigth encoder (motor) */ BusOut NibbleLEDs(P1_8, P1_9, P1_10, P1_11); /**< 4 yellow LEDs as a bus defined; use it i.e.: karel.NibbleLeds(karel.GetLineValues()); to show line sensor values */ DigitalOut LED_D10(P1_8); /**< wiring first LED_D10 */
--- a/const.h Sun Apr 26 20:04:47 2015 +0000 +++ b/const.h Mon Apr 27 13:13:45 2015 +0000 @@ -1,6 +1,6 @@ /*! \file const.h \brief A Documented file. -* name: const.h Version: 2.2 \n +* name: const.h Version: 3.0 \n * author: PE HTL BULME \n * email: pe@bulme.at \n * description: @@ -62,6 +62,4 @@ const int West = 2; const int North = 3; const int South = 4; - - #endif \ No newline at end of file
--- a/ur_Bertl.cpp Sun Apr 26 20:04:47 2015 +0000
+++ b/ur_Bertl.cpp Mon Apr 27 13:13:45 2015 +0000
@@ -1,5 +1,6 @@
/***********************************
-name: ur_Bertl.cpp Version: 2.2
+name: ur_Bertl.cpp Version: 3.0
+ class Bertl included
author: PE HTL BULME
email: pe@bulme.at
WIKI: https://developer.mbed.org/teams/BERTL_CHEL_18/code/ur_Bertl/
@@ -13,7 +14,7 @@
#include "ur_Bertl.h"
// Constructor
-ur_Bertl::ur_Bertl() : _interrupt(P1_12) // left sensor P1_13
+ur_Bertl::ur_Bertl() : _interrupt(MOTORENC)
{
i2c.frequency(40000); // I2C init
char init1[2] = {0x6, 0x00};
@@ -374,7 +375,7 @@
}
// -------------------- BERTL CLASS -------------------------------------
-void Bertl::MoveBackwards(int move)
+int Bertl::MoveBackwards(int move)
{
int count = _count;
//wait_ms(250); // waite until Bertl stops
@@ -393,8 +394,35 @@
MotorR_EN=MotorL_EN=0;
if(move == MOVE)
wait_ms(250);
+ return _count - count;
}
// ------------------------- BERT CLASS --------------------------------------
+int Bertl::Move(int move)
+{
+ int count = _count;
+ MotorR_EN=MotorL_EN=1; // both motor ENABLE
+ MotorR_FORWARD = MotorL_FORWARD = 1; // both motor forward ON
+#ifdef TIME
+ wait_ms(move);
+#else
+
+ while(_count < count+move) {
+ //if(!FrontIsClear()) // more convenient because there are no accidents :-)
+ // break;
+#ifdef FRONTBUTTON
+ if(frontButtonPressed())
+ error();
+#endif
+ DEBUG_PRINT("count: %d _count: %d", count, _count);
+ }
+#endif
+ MotorR_FORWARD = MotorL_FORWARD = 0; // both motor off
+ MotorR_EN=MotorL_EN=0;
+ if(move == MOVE)
+ wait_ms(250);
+ return _count - count;
+}
+
void Bertl::TurnRigth()
{
int count = _count;
@@ -475,4 +503,11 @@
detect = linesensor;
return detect;
-}
\ No newline at end of file
+}
+
+void Bertl::RGBLed(bool red, bool green, bool blue)
+{
+ RGB_blue=!blue;
+ RGB_red=!red;
+ RGB_green=!green;
+}
--- a/ur_Bertl.h Sun Apr 26 20:04:47 2015 +0000
+++ b/ur_Bertl.h Mon Apr 27 13:13:45 2015 +0000
@@ -1,5 +1,6 @@
/***********************************
-name: ur_Bertl.h Version: 2.2
+name: ur_Bertl.h Version: 3.0
+ class Bertl included
author: PE HTL BULME
email: pe@bulme.at
WIKI: https://developer.mbed.org/teams/BERTL_CHEL_18/code/ur_Bertl/
@@ -18,7 +19,8 @@
#define RIGHTSENSOR P1_13
/********************************************//**
name: ur_Bertl.h \n
- version: 2.2 \n
+ version: 3.0 \n
+ class Bertl included \n
author:PE HTL BULME \n
email: pe@bulme.at \n
WIKI: https://developer.mbed.org/teams/BERTL_CHEL_18/code/ur_Bertl/wiki/Homepage \n
@@ -167,7 +169,7 @@
};
/********************************************//**
name: Bertl.h \n
- version: 1.0 \n
+ version: 3.0 \n
author:PE HTL BULME \n
email: pe@bulme.at \n
WIKI: https://developer.mbed.org/teams/BERTL_CHEL_18/code/ur_Bertl/wiki/Homepage \n
@@ -236,10 +238,12 @@
protected:
public:
//Bertl(); /**< default constructor; you have to define constants in config.h such as SPEED, DISTANCE or ANGLE*/
- void MoveBackwards(int move = MOVE); /**< Robot moves as much back as the constant DISTANCE; if one of the buttons fire --> Error()*/
+ int Move(int move = MOVE); /**< Robot moves one turn as much as the constant DISTANCE; if one of the buttons fire --> Error()*/
+ int MoveBackwards(int move = MOVE); /**< Robot moves as much back as the constant DISTANCE; if one of the buttons fire --> Error()*/
void TurnRigth(); /**< Robot turns rigth as much as the constant ANGLE*/
void TurnLeftStep(int step=STEPTIME); /**< Robot turns left for a short time defined in STEPTIME */
void TurnRigthStep(int step=STEPTIME); /**< Robot turns rigth for a short time defined in STEPTIME */
uint8_t GetLineValues(); /**< in the lower 4 bit are the values of the line sensor */
+ void RGBLed(bool red, bool green, bool blue); /**<RGB Led with red, green and blue component of the Color */
};
#endif
\ No newline at end of file
