robot arm demo team / Mbed 2 deprecated RobotArmDemo Featured

Dependencies:   AX-12A Dynamixel mbed iothub_client EthernetInterface NTPClient ConfigFile SDFileSystem iothub_amqp_transport mbed-rtos proton-c-mbed wolfSSL

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ControllerIo.cpp Source File

ControllerIo.cpp

00001 // Copyright (c) Microsoft. All rights reserved.
00002 // Licensed under the MIT license. See LICENSE file in the project root for full license information.
00003 
00004 #include "mbed.h"
00005 #include "rtos.h"
00006 
00007 DigitalOut greenLed(LED_GREEN);
00008 DigitalOut redLed(LED_RED);
00009 DigitalOut blueLed(LED_BLUE);
00010 
00011 DigitalOut buzzer(D2, 1);
00012 
00013 
00014 int BuzzStopMs = 0;
00015 
00016 void ShowLedColor(int col)
00017 {
00018     greenLed = 1;
00019     redLed = 1;
00020     blueLed = 1;
00021     
00022     if (col == 1)
00023         greenLed = 0;
00024     else if (col == 2)
00025         redLed = 0;
00026     else if (col == 3)
00027         blueLed = 0;
00028 }
00029 
00030 void ShowLedGreen()
00031 {
00032     ShowLedColor(1);
00033 }
00034 
00035 void ShowLedRed()
00036 {
00037     ShowLedColor(2);
00038 }
00039 
00040 void ShowLedBlue()
00041 {
00042     ShowLedColor(3);
00043 }
00044 
00045 void BuzzerStart()
00046 {
00047     buzzer = 0;
00048 }
00049 
00050 void BuzzerStop()
00051 {
00052     buzzer = 1;
00053 }
00054 
00055 void BuzzerStartMs(int nowMs, int durationMs)
00056 {
00057     BuzzStopMs = nowMs + durationMs;
00058     BuzzerStart();
00059 }
00060 
00061 void BuzzerPoll(int nowMs)
00062 {
00063     if (BuzzStopMs != 0)
00064     {
00065         if (nowMs >= BuzzStopMs)
00066         {
00067             BuzzStopMs = 0;
00068             BuzzerStop();
00069         }
00070     }
00071 }