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 1:fafbac0ba96d, committed 2015-03-19
- Comitter:
- bulmecisco
- Date:
- Thu Mar 19 19:12:33 2015 +0000
- Parent:
- 0:66e9a0afcbd6
- Child:
- 2:1cd559ff516b
- Commit message:
- FrontIsClear() with ultrasonic sensor added
Changed in this revision
--- a/config.h Thu Feb 26 10:12:06 2015 +0000 +++ b/config.h Thu Mar 19 19:12:33 2015 +0000 @@ -16,7 +16,8 @@ /*! \def DEBUG \brief Turns debugging infos off (0) and on (3) which are send to serial pc.uart */ #define DEBUG 0 -//#define FRONTBUTTON +#define FRONTBUTTON /**< Error shutoff if Bertl moves against a wall*/ +#define HCSR /**< if ultrsonic is installed*/ BusOut NibbleLEDs(P1_8, P1_9, P1_10, P1_11); /**< 4 yellow LEDs as a bus defined */ DigitalOut LED_D10(P1_8); /**< wiring first LED_D10 */
--- a/const.h Thu Feb 26 10:12:06 2015 +0000 +++ b/const.h Thu Mar 19 19:12:33 2015 +0000 @@ -44,6 +44,8 @@ const int LED_ALL_BACK = 0xF0; const int LED_ALL = 0xFF; +const int LED_BLUE = 0xBB; + const int addr = 0x40; // I2C-address PCA9555 const int PERIOD = 20; // PWM period const int PULSWIDTH = 5; // PWN pulswidth
--- a/ur_Bertl.cpp Thu Feb 26 10:12:06 2015 +0000
+++ b/ur_Bertl.cpp Thu Mar 19 19:12:33 2015 +0000
@@ -140,6 +140,13 @@
{
char cmd[3];
+ if(led == 0xBB) {
+ LED_blue=0;
+ return;
+ } else if (led == 0xFF) {
+ RGBLed(1,1,1);
+ LED_blue=0;
+ }
cmd[0] = 0x02;
cmd[1] = ~led;
i2c.write(addr, cmd, 2);
@@ -149,7 +156,13 @@
void ur_Bertl::TurnLedOff(int16_t led)
{
char cmd[3];
-
+ if(led == 0xBB) {
+ LED_blue=1;
+ return;
+ } else if (led == 0xFF) {
+ RGBLed(0,0,0); //don't work?
+ LED_blue=1;
+ }
cmd[0] = 0x02;
cmd[1] = led;
i2c.write(addr, cmd, 2);
@@ -217,9 +230,10 @@
}
//----------------------------------------------------------------------
-/*
+
bool ur_Bertl::FrontIsClear()
{
+#ifdef HCSR
int dist = 0;
usensor.start();
wait_ms(10);
@@ -228,8 +242,7 @@
return false;
else
return true;
- DEBUG_PRINT("Distance: %d", dist);
-
+#else
// if there is no ultra sonic sensor use this - with front buttons
char cmd[3]; // array for I2C
int16_t btns;
@@ -249,9 +262,10 @@
wert = true;
DEBUG_PRINT("WERT: %d", wert);
return wert;
+#endif
}
-
+/*
bool ur_Bertl::NextToABeeper()
{
if (BottomIsBlack())
--- a/ur_Bertl.h Thu Feb 26 10:12:06 2015 +0000
+++ b/ur_Bertl.h Thu Mar 19 19:12:33 2015 +0000
@@ -116,6 +116,7 @@
void TurnLeft(); /**< Robot turns left as much as the constant ANGLE*/
void PutBeeper(); /**< if Robot has any Beepers in his bag he can put one or more Beeper; if not --> Error(()*/
void PickBeeper(); /**< if Robot stands on a black item he can pick one or more Beeper (max. 16 --> Error()); if not --> Error()*/
+ bool FrontIsClear(); /**< returns a boolean value true if front is free; if not false */
void NibbleLeds(int value); /**< methode for the 4 (half byte) yellow LEDs at the back left side */
void TurnLedOn(int16_t led);/**< turns the specified one or more LEDs ON; description and name in const.h, such as LED_FL1 = 0x01; front LED white */
void TurnLedOff(int16_t led);/**< turns the specified one or more LEDs OFF; description and name in const.h, such as LED_FL1 = 0x01; front LED white */
