robobuggy / arduino / RCbuggyMega / brake.c @ 0c873a67
History | View | Annotate | Download (739 Bytes)
1 |
/**
|
---|---|
2 |
* @file brake.c
|
3 |
* @author Audrey Yeoh (ayeoh)
|
4 |
* @author Matt Sebek (msebek)
|
5 |
*/
|
6 |
#include <Arduino.h> |
7 |
#include "brake.h" |
8 |
|
9 |
static int brake_pin; |
10 |
// Indicator LED pin number
|
11 |
static int indicator_pin; |
12 |
|
13 |
void brake_init(int brakePin, int indicatorLed) { |
14 |
pinMode(brake_pin, OUTPUT); |
15 |
pinMode(indicatorLed, OUTPUT); |
16 |
brake_pin = brakePin; |
17 |
indicator_pin = indicatorLed; |
18 |
} |
19 |
|
20 |
// Note: High-voltage raises the brake.
|
21 |
// Raises the brake
|
22 |
// Do not call before brake_init
|
23 |
void brake_raise() {
|
24 |
digitalWrite(brake_pin, HIGH); |
25 |
digitalWrite(indicator_pin, LOW); |
26 |
} |
27 |
|
28 |
// Drops the brake
|
29 |
// Do not call before brake_init
|
30 |
void brake_drop() {
|
31 |
digitalWrite(brake_pin, LOW); |
32 |
digitalWrite(indicator_pin, HIGH); |
33 |
} |