Leds work simultanously. Version 3.1

Dependencies:   HCSR

Dependents:   bertl_led bertl_led bertl_led bertl_led ... more

Fork of Bertl by Bertl_Team_PE

BULME HTL Graz-Gösting

FSST - Hardwarenahe Programmierung

Created by Prof.Dr. Franz Pucher

Inhalt

Inhalt

Start mit folgendem Code in main.cpp eines neuen Projektes mbed_blinky:

#include "mbed.h"
#include "const.h"
#include "Robot.h"

Robot bertl;
    
int main()
{
    bertl.NibbleLeds(0x0F);
    wait(1);
    bertl.NibbleLeds(0x00);
    
    while(1)
    {
        if(bertl.IsButtonPressed(BTN_BL))
        {
            bertl.TurnLedOn(LED_BL1);
        }
        if(bertl.IsButtonPressed(BTN_BR))
        {
            bertl.TurnLedOff(LED_BL1);
        }
    }
}

Files at this revision

API Documentation at this revision

Comitter:
fpucher
Date:
Fri Feb 19 15:28:42 2016 +0000
Parent:
17:308802267a62
Commit message:
Version 3.2

Changed in this revision

Robot.h Show annotated file Show diff for this revision Revisions of this file
config.h Show annotated file Show diff for this revision Revisions of this file
const.h Show annotated file Show diff for this revision Revisions of this file
ur_Bertl.cpp Show annotated file Show diff for this revision Revisions of this file
ur_Bertl.h Show annotated file Show diff for this revision Revisions of this file
diff -r 308802267a62 -r e9bb4513ae3a Robot.h
--- a/Robot.h	Thu Nov 12 19:05:56 2015 +0000
+++ b/Robot.h	Fri Feb 19 15:28:42 2016 +0000
@@ -14,7 +14,7 @@
 #ifndef ROBOT_H
 #define ROBOT_H
 
-class Robot : public ur_Bertl
+class Robot : public Bertl
 {
 public:
     Robot() {};
diff -r 308802267a62 -r e9bb4513ae3a config.h
--- a/config.h	Thu Nov 12 19:05:56 2015 +0000
+++ b/config.h	Fri Feb 19 15:28:42 2016 +0000
@@ -1,6 +1,6 @@
 /*! \file config.h
 \brief A Documented file.
-* name:   config.h    Version: 3.0 \n
+* name:   config.h    Version: 3.2 \n
 * author: PE HTL BULME \n
 * email:  pe@bulme.at \n
 * description:
@@ -18,7 +18,7 @@
 #define DEBUG 0
 //#define FRONTBUTTON       /**< Error shutoff if Bertl moves against a wall*/
 #define HCSR                /**< if ultrsonic is installed*/
-#define MOTORENC P1_13        /**< P1_12: left encoder P1_13: rigth encoder (motor) */
+#define MOTORENC P1_13        /**< P1_12: left encoder P1_13: right 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 */
@@ -43,7 +43,9 @@
 DigitalOut MotorR_REVERSE(P1_4);    // change to P1_3 for Bertl 2015
 
 I2C i2c(p28,p27);   
+// InterruptIn PushButton(P0_8);    // Interrupt I2C Tasten
 BusIn linesensor(p18, p16, p19, p17);  
+BusIn linesensor5(p18, p16, p20, p19, p17); /**<  Bertl15 additonal Sensor in the middle */
 DigitalIn SensorL(P1_12);     /**<  motor sensor left on Port P1_12 */
 DigitalIn SensorR(P1_13);     /**<  motor sensor right on Port P1_13 */
 HCSR04  usensor(p21,p22);     // HC-SR04 ultrasonic sensor
diff -r 308802267a62 -r e9bb4513ae3a const.h
--- a/const.h	Thu Nov 12 19:05:56 2015 +0000
+++ b/const.h	Fri Feb 19 15:28:42 2016 +0000
@@ -1,6 +1,6 @@
 /*! \file const.h
 \brief A Documented file.
-* name:   const.h    Version: 3.0 \n
+* name:   const.h    Version: 3.2 \n
 * author: PE HTL BULME \n
 * email:  pe@bulme.at \n
 * description:
@@ -11,17 +11,17 @@
 #define CONST_H
 #define TIME  /**< if defined Bertl uses the time and not motor encoder*/
 const int MOVE=500;     /**< ms move forward or backward */
-const int TURN=500;     /**< ms TurnLeft or TurnRigth (nearly 90 degree) */
-const int STEPTIME=20;  /**< ms turn left or right for adjusting moves for TurnLeft or TurnRigth */
+const int TURN=500;     /**< ms TurnLeft or TurnRight (nearly 90 degree) */
+const int STEPTIME=20;  /**< ms turn left or right for adjusting moves for TurnLeft or TurnRight */
 
 /*! \var int ULTRASONIC_DISTANCE
 \brief Bertl Ultrasonic Distance Sensor from 1 to n; 5 is ok for nearly 5 cm.
 \warning no warning*/
-const int ULTRASONIC_DISTANCE = 5;    /*  Distance sensor  */
+const int ULTRASONIC_DISTANCE = 6;    /*  Distance sensor  */
 /*! \var int SPEED
 \brief Bertl speed 0.2 (slow) - 1.0 (fast).
 \warning speed below 0.2 possible the motor won't start */
-const float SPEED = 0.4;    /*  Bertl speed 0.2 (slow) - 1.0 (fast) */
+const float SPEED = 0.1;    /*  Bertl speed 0.2 (slow) - 1.0 (fast) */
 /*! \var int DISTANCE
 \brief one wheel turn is appr. 24 ticks.
 \warning maybe the number has to be adjusted */
diff -r 308802267a62 -r e9bb4513ae3a ur_Bertl.cpp
--- a/ur_Bertl.cpp	Thu Nov 12 19:05:56 2015 +0000
+++ b/ur_Bertl.cpp	Fri Feb 19 15:28:42 2016 +0000
@@ -1,5 +1,5 @@
 /***********************************
-name:   ur_Bertl.cpp    Version: 3.0
+name:   ur_Bertl.cpp    Version: 3.2
         class Bertl included
 author: PE HTL BULME
 email:  pe@bulme.at
@@ -437,7 +437,7 @@
     return _count - count;
 }
 
-void Bertl::TurnRigth()
+void Bertl::TurnRight()
 {
     int count = _count;
     MotorR_EN=MotorL_EN=1;                  // motor left and right ENABLE
@@ -462,7 +462,7 @@
     wait_ms(250);           // only to step the robot
 }
 // ------------------------- to adjust turns ---------------------------------
-void Bertl::TurnRigthStep(int step)
+void Bertl::TurnRightStep(int step)
 {
     int count = _count;
     MotorR_EN=MotorL_EN=1;                  // motor left and right ENABLE
@@ -518,6 +518,14 @@
     detect = linesensor;
     return detect;
 }
+// Bertl15: 5 sensors are available
+uint8_t Bertl::GetLineValues5()
+{
+    uint8_t detect;
+    
+    detect = linesensor5;
+    return detect;
+}
 
 void Bertl::RGBLed(bool red, bool green, bool blue)
 {
diff -r 308802267a62 -r e9bb4513ae3a ur_Bertl.h
--- a/ur_Bertl.h	Thu Nov 12 19:05:56 2015 +0000
+++ b/ur_Bertl.h	Fri Feb 19 15:28:42 2016 +0000
@@ -1,12 +1,12 @@
 /***********************************
-name:   ur_Bertl.h      Version: 3.0
+name:   ur_Bertl.h      Version: 3.2
         class Bertl included
 author: PE HTL BULME
 email:  pe@bulme.at
 WIKI:   https://developer.mbed.org/teams/BERTL_CHEL_18/code/ur_Bertl/
 description:
         Definition portion of the class ur_Bertl The Robot
-        Step wise turns on left and rigth
+        Step wise turns on left and Right
         int ReturnButtonPressed() added which returns the int value of button pressed 
 ***********************************/
 #include "mbed.h"
@@ -224,7 +224,7 @@
             karel.TurnLeftStep(20);
             break;
         case 0x0E: case 0x0A: case 0x08:
-            karel.TurnRigthStep(20);
+            karel.TurnRightStep(20);
             break;
         default:
             karel.Move(20);
@@ -243,10 +243,11 @@
     //Bertl();                 /**< default constructor; you have to define constants in config.h such as SPEED, DISTANCE or ANGLE*/
     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 TurnRight();           /**< Robot turns Right 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 */
+    void TurnRightStep(int step=STEPTIME);  /**< Robot turns Right for a short time defined in STEPTIME */
     uint8_t GetLineValues();    /**< in the lower 4 bit are the values of the line sensor */
+    uint8_t GetLineValues5();    /**< Bertl15: lower 5 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