Basic ledControl library that control the leds on LPC1768

Dependents:   gimbalController_brushless_IMU i2c_MPU6050 i2c_HMC5883L IMU_fusion ... more

Committer:
BaserK
Date:
Tue Jul 21 08:19:15 2015 +0000
Revision:
2:1655ee0ec2ca
Parent:
1:7ffaf6e46589
comment update;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
BaserK 1:7ffaf6e46589 1 /*
BaserK 1:7ffaf6e46589 2 * Copyright (c) 2015, Baser Kandehir, baser.kandehir@ieee.metu.edu.tr
BaserK 1:7ffaf6e46589 3 *
BaserK 1:7ffaf6e46589 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
BaserK 1:7ffaf6e46589 5 * of this software and associated documentation files (the "Software"), to deal
BaserK 1:7ffaf6e46589 6 * in the Software without restriction, including without limitation the rights
BaserK 1:7ffaf6e46589 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
BaserK 1:7ffaf6e46589 8 * copies of the Software, and to permit persons to whom the Software is
BaserK 1:7ffaf6e46589 9 * furnished to do so, subject to the following conditions:
BaserK 1:7ffaf6e46589 10 *
BaserK 1:7ffaf6e46589 11 * The above copyright notice and this permission notice shall be included in
BaserK 1:7ffaf6e46589 12 * all copies or substantial portions of the Software.
BaserK 1:7ffaf6e46589 13 *
BaserK 1:7ffaf6e46589 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
BaserK 1:7ffaf6e46589 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
BaserK 1:7ffaf6e46589 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
BaserK 1:7ffaf6e46589 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
BaserK 1:7ffaf6e46589 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
BaserK 1:7ffaf6e46589 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
BaserK 1:7ffaf6e46589 20 * THE SOFTWARE.
BaserK 1:7ffaf6e46589 21 *
BaserK 1:7ffaf6e46589 22 */
BaserK 1:7ffaf6e46589 23
BaserK 0:0afc4bd76407 24 #include "ledControl.h"
BaserK 0:0afc4bd76407 25
BaserK 0:0afc4bd76407 26 DigitalOut led1(LED1);
BaserK 0:0afc4bd76407 27 DigitalOut led2(LED2);
BaserK 0:0afc4bd76407 28 DigitalOut led3(LED3);
BaserK 0:0afc4bd76407 29 DigitalOut led4(LED4);
BaserK 0:0afc4bd76407 30
BaserK 0:0afc4bd76407 31 // Controls the 4 LEDs on the LPC1768
BaserK 0:0afc4bd76407 32 void ledControl(int ledNum,int value)
BaserK 0:0afc4bd76407 33 {
BaserK 0:0afc4bd76407 34 switch(ledNum)
BaserK 0:0afc4bd76407 35 {
BaserK 0:0afc4bd76407 36 case 1: led1.write(value);
BaserK 0:0afc4bd76407 37 break;
BaserK 0:0afc4bd76407 38
BaserK 0:0afc4bd76407 39 case 2: led2.write(value);
BaserK 0:0afc4bd76407 40 break;
BaserK 0:0afc4bd76407 41
BaserK 0:0afc4bd76407 42 case 3: led3.write(value);
BaserK 0:0afc4bd76407 43 break;
BaserK 0:0afc4bd76407 44
BaserK 0:0afc4bd76407 45 case 4: led4.write(value);
BaserK 0:0afc4bd76407 46 break;
BaserK 0:0afc4bd76407 47 }
BaserK 0:0afc4bd76407 48 }
BaserK 0:0afc4bd76407 49
BaserK 0:0afc4bd76407 50 // Toggles the specified led
BaserK 0:0afc4bd76407 51 void ledToggle(int ledNum)
BaserK 0:0afc4bd76407 52 {
BaserK 0:0afc4bd76407 53 switch(ledNum)
BaserK 0:0afc4bd76407 54 {
BaserK 0:0afc4bd76407 55 case 1: led1=!led1;
BaserK 0:0afc4bd76407 56 break;
BaserK 0:0afc4bd76407 57
BaserK 0:0afc4bd76407 58 case 2: led2=!led2;
BaserK 0:0afc4bd76407 59 break;
BaserK 0:0afc4bd76407 60
BaserK 0:0afc4bd76407 61 case 3: led3=!led3;
BaserK 0:0afc4bd76407 62 break;
BaserK 0:0afc4bd76407 63
BaserK 0:0afc4bd76407 64 case 4: led4=!led4;
BaserK 0:0afc4bd76407 65 break;
BaserK 0:0afc4bd76407 66 }
BaserK 0:0afc4bd76407 67 }