Adding an astyle make target and running everything through it
This commit is contained in:
@@ -4,24 +4,24 @@ const unsigned int FLASH_DURATION = 100;
|
||||
|
||||
|
||||
void flash(int n) {
|
||||
for (int i = 0; i < n; i++) {
|
||||
digitalWrite(LED_PIN, HIGH);
|
||||
delay(FLASH_DURATION);
|
||||
digitalWrite(LED_PIN, LOW);
|
||||
delay(FLASH_DURATION);
|
||||
}
|
||||
for (int i = 0; i < n; i++) {
|
||||
digitalWrite(LED_PIN, HIGH);
|
||||
delay(FLASH_DURATION);
|
||||
digitalWrite(LED_PIN, LOW);
|
||||
delay(FLASH_DURATION);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void setup() {
|
||||
pinMode(LED_PIN, OUTPUT);
|
||||
pinMode(LED_PIN, OUTPUT);
|
||||
}
|
||||
|
||||
|
||||
void loop() {
|
||||
for (int i = 1; i < 4; i++) {
|
||||
flash(i);
|
||||
for (int i = 1; i < 4; i++) {
|
||||
flash(i);
|
||||
delay(PAUSE);
|
||||
}
|
||||
delay(PAUSE);
|
||||
}
|
||||
delay(PAUSE);
|
||||
}
|
||||
|
@@ -2,53 +2,53 @@ const unsigned int LED_PIN = 13;
|
||||
const unsigned int BAUD_RATE = 9600;
|
||||
|
||||
void ledOn() {
|
||||
digitalWrite(LED_PIN, HIGH);
|
||||
Serial.println("LED on");
|
||||
digitalWrite(LED_PIN, HIGH);
|
||||
Serial.println("LED on");
|
||||
}
|
||||
|
||||
void ledOff() {
|
||||
digitalWrite(LED_PIN, LOW);
|
||||
Serial.println("LED off");
|
||||
digitalWrite(LED_PIN, LOW);
|
||||
Serial.println("LED off");
|
||||
}
|
||||
|
||||
void ledBlink() {
|
||||
Serial.println("BLINKY TIME");
|
||||
for (int i = 0; i < 5; i++) {
|
||||
ledOn();
|
||||
delay(100);
|
||||
ledOff();
|
||||
delay(100);
|
||||
}
|
||||
Serial.println("BLINKY TIME");
|
||||
for (int i = 0; i < 5; i++) {
|
||||
ledOn();
|
||||
delay(100);
|
||||
ledOff();
|
||||
delay(100);
|
||||
}
|
||||
}
|
||||
|
||||
void handleInput() {
|
||||
int c = Serial.read();
|
||||
int c = Serial.read();
|
||||
|
||||
switch (c) {
|
||||
case '1':
|
||||
ledOn();
|
||||
break;
|
||||
case '2':
|
||||
ledOff();
|
||||
break;
|
||||
case '3':
|
||||
ledBlink();
|
||||
break;
|
||||
default:
|
||||
Serial.print("Unknown command: ");
|
||||
Serial.println(c);
|
||||
}
|
||||
switch (c) {
|
||||
case '1':
|
||||
ledOn();
|
||||
break;
|
||||
case '2':
|
||||
ledOff();
|
||||
break;
|
||||
case '3':
|
||||
ledBlink();
|
||||
break;
|
||||
default:
|
||||
Serial.print("Unknown command: ");
|
||||
Serial.println(c);
|
||||
}
|
||||
}
|
||||
|
||||
void setup() {
|
||||
pinMode(LED_PIN, OUTPUT);
|
||||
Serial.begin(BAUD_RATE);
|
||||
pinMode(LED_PIN, OUTPUT);
|
||||
Serial.begin(BAUD_RATE);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (Serial.available() <= 0) {
|
||||
return;
|
||||
}
|
||||
if (Serial.available() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
handleInput();
|
||||
handleInput();
|
||||
}
|
||||
|
@@ -13,7 +13,7 @@ void loop() {
|
||||
const int CURRENT_BUTTON_STATE = digitalRead(BUTTON_PIN);
|
||||
|
||||
if (CURRENT_BUTTON_STATE != oldButtonState &&
|
||||
CURRENT_BUTTON_STATE == HIGH) {
|
||||
CURRENT_BUTTON_STATE == HIGH) {
|
||||
if (ledState == LOW) {
|
||||
ledState = HIGH;
|
||||
} else {
|
||||
|
@@ -13,7 +13,7 @@ void loop() {
|
||||
const int CURRENT_BUTTON_STATE = digitalRead(BUTTON_PIN);
|
||||
|
||||
if (CURRENT_BUTTON_STATE != oldButtonState &&
|
||||
CURRENT_BUTTON_STATE == HIGH) {
|
||||
CURRENT_BUTTON_STATE == HIGH) {
|
||||
if (ledState == LOW) {
|
||||
ledState = HIGH;
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user