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);
        }
    }
}
Revision:
3:01b183fe8b41
Parent:
2:1cd559ff516b
Child:
4:76acfddc26fb
--- a/ur_Bertl.cpp	Thu Mar 26 12:39:40 2015 +0000
+++ b/ur_Bertl.cpp	Thu Mar 26 13:06:00 2015 +0000
@@ -15,6 +15,10 @@
 ur_Bertl::ur_Bertl() : _interrupt(P1_12)            // left sensor P1_13
 {
     i2c.frequency(40000);                           // I2C Frequenz 40kHz
+    char init1[2] = {0x6, 0x00};
+    char init2[2] = {0x7, 0xff};
+    i2c.write(0x40, init1, 2);
+    i2c.write(0x40, init2, 2);
     mg1 = mg2 = SPEED;
     _interrupt.rise(this, &ur_Bertl::increment);    // attach increment function of this counter instance ie. motor sensor
     _count = 0;
@@ -24,6 +28,10 @@
 ur_Bertl::ur_Bertl(PinName pin) :  _interrupt(pin)  // create the InterruptIn on the pin specified to Counter
 {
     i2c.frequency(40000);                           // I2C Frequenz 40kHz
+    char init1[2] = {0x6, 0x00};
+    char init2[2] = {0x7, 0xff};
+    i2c.write(0x40, init1, 2);
+    i2c.write(0x40, init2, 2);
     mg1 = mg2 = SPEED;
     _interrupt.rise(this, &ur_Bertl::increment);    // attach increment function of this counter instance ie. motor sensor
     _count = 0;
@@ -39,7 +47,7 @@
     MotorR_FORWARD = MotorL_FORWARD = 1;    // both motor forward ON
 #ifdef TIME
     wait_ms(MOVE);
-#else    
+#else
 
     while(_count < count+DISTANCE) {
         //if(!FrontIsClear())       // more convenient because there are no accidents :-)