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);
        }
    }
}
Committer:
bulmecisco
Date:
Thu Feb 26 10:12:06 2015 +0000
Revision:
0:66e9a0afcbd6
Child:
1:fafbac0ba96d
ur_Bertl based on simple class design with documentaton

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bulmecisco 0:66e9a0afcbd6 1 /*! \file const.h
bulmecisco 0:66e9a0afcbd6 2 \brief A Documented file.
bulmecisco 0:66e9a0afcbd6 3 * name: const.h Version: 1.0
bulmecisco 0:66e9a0afcbd6 4 * author: PE HTL BULME
bulmecisco 0:66e9a0afcbd6 5 * email: pe@bulme.at
bulmecisco 0:66e9a0afcbd6 6 * description:
bulmecisco 0:66e9a0afcbd6 7 * Constants for ur_Bertl The Robot
bulmecisco 0:66e9a0afcbd6 8 */
bulmecisco 0:66e9a0afcbd6 9 #ifndef CONST_H
bulmecisco 0:66e9a0afcbd6 10 #define CONST_H
bulmecisco 0:66e9a0afcbd6 11
bulmecisco 0:66e9a0afcbd6 12 /*! \var int SPEED
bulmecisco 0:66e9a0afcbd6 13 \brief Bertl speed 0.2 (slow) - 1.0 (fast).
bulmecisco 0:66e9a0afcbd6 14 \warning speed below 0.2 possible the motor won't start */
bulmecisco 0:66e9a0afcbd6 15 const float SPEED = 0.2; /* Bertl speed 0.2 (slow) - 1.0 (fast) */
bulmecisco 0:66e9a0afcbd6 16 /*! \var int DISTANCE
bulmecisco 0:66e9a0afcbd6 17 \brief one wheel turn is appr. 24 ticks.
bulmecisco 0:66e9a0afcbd6 18 \warning maybe the number has to be adjusted */
bulmecisco 0:66e9a0afcbd6 19 const int DISTANCE = 24; /* one wheel turn is appr. 24 ticks */
bulmecisco 0:66e9a0afcbd6 20 /*! \var int ANGLE
bulmecisco 0:66e9a0afcbd6 21 \brief 12 is nearly 90 degree turn left.
bulmecisco 0:66e9a0afcbd6 22 \warning maybe the number has to be adjusted */
bulmecisco 0:66e9a0afcbd6 23 const int ANGLE = 12; /* nearly 90 degree turn left */
bulmecisco 0:66e9a0afcbd6 24
bulmecisco 0:66e9a0afcbd6 25 const int BTN_FLL = 0x80; // button front left outer
bulmecisco 0:66e9a0afcbd6 26 const int BTN_FL = 0x04; // button front left
bulmecisco 0:66e9a0afcbd6 27 const int BTN_FM = 0x01; // button front middle
bulmecisco 0:66e9a0afcbd6 28 const int BTN_FR = 0x08; // button front right
bulmecisco 0:66e9a0afcbd6 29 const int BTN_FRR = 0x40; // button front right outer
bulmecisco 0:66e9a0afcbd6 30 const int BTN_BL = 0x10; // button back left
bulmecisco 0:66e9a0afcbd6 31 const int BTN_BM = 0x02; // button back middle
bulmecisco 0:66e9a0afcbd6 32 const int BTN_BR = 0x20; // button back right
bulmecisco 0:66e9a0afcbd6 33
bulmecisco 0:66e9a0afcbd6 34 const int LED_FL1 = 0x01; /**< front LED white */
bulmecisco 0:66e9a0afcbd6 35 const int LED_FL2 = 0x02; /**< front LED yellow */
bulmecisco 0:66e9a0afcbd6 36 const int LED_FR1 = 0x04; /**< front LED white */
bulmecisco 0:66e9a0afcbd6 37 const int LED_FR2 = 0x08; /**< front LED yellow */
bulmecisco 0:66e9a0afcbd6 38 const int LED_ALL_FRONT = 0x0F;
bulmecisco 0:66e9a0afcbd6 39
bulmecisco 0:66e9a0afcbd6 40 const int LED_BL1 = 0x20; /**< yellow LED back left outer */
bulmecisco 0:66e9a0afcbd6 41 const int LED_BL2 = 0x10; /**< red LED back left inner */
bulmecisco 0:66e9a0afcbd6 42 const int LED_BR1 = 0x80; /**< yellow LED back right outer */
bulmecisco 0:66e9a0afcbd6 43 const int LED_BR2 = 0x40; /**< red LED back right inner */
bulmecisco 0:66e9a0afcbd6 44 const int LED_ALL_BACK = 0xF0;
bulmecisco 0:66e9a0afcbd6 45 const int LED_ALL = 0xFF;
bulmecisco 0:66e9a0afcbd6 46
bulmecisco 0:66e9a0afcbd6 47 const int addr = 0x40; // I2C-address PCA9555
bulmecisco 0:66e9a0afcbd6 48 const int PERIOD = 20; // PWM period
bulmecisco 0:66e9a0afcbd6 49 const int PULSWIDTH = 5; // PWN pulswidth
bulmecisco 0:66e9a0afcbd6 50
bulmecisco 0:66e9a0afcbd6 51
bulmecisco 0:66e9a0afcbd6 52 #endif