Emit Strobe for second LED
This commit is contained in:
34
src/main.cpp
34
src/main.cpp
@@ -1,5 +1,7 @@
|
|||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
static uint8_t led_duration = 4;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Function: configureTimer
|
* Function: configureTimer
|
||||||
* ----------------------------
|
* ----------------------------
|
||||||
@@ -55,6 +57,7 @@ void setup()
|
|||||||
|
|
||||||
Serial.println("set output pins...");
|
Serial.println("set output pins...");
|
||||||
pinMode(2, OUTPUT);
|
pinMode(2, OUTPUT);
|
||||||
|
pinMode(3, OUTPUT);
|
||||||
pinMode(9, OUTPUT);
|
pinMode(9, OUTPUT);
|
||||||
pinMode(7, INPUT);
|
pinMode(7, INPUT);
|
||||||
|
|
||||||
@@ -73,8 +76,11 @@ void loop()
|
|||||||
uint32_t period = 0;
|
uint32_t period = 0;
|
||||||
uint16_t rotations = 0;
|
uint16_t rotations = 0;
|
||||||
|
|
||||||
uint16_t led_period = (uint16_t)-1;
|
uint16_t led_a_period = (uint16_t)-1;
|
||||||
uint16_t led_counter = led_period;
|
uint16_t led_a_counter = led_a_period;
|
||||||
|
|
||||||
|
uint16_t led_b_period = (uint16_t)-1;
|
||||||
|
uint16_t led_b_counter = led_b_period;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
iterator++;
|
iterator++;
|
||||||
@@ -88,22 +94,34 @@ void loop()
|
|||||||
} else {
|
} else {
|
||||||
tacho_counter = 0;
|
tacho_counter = 0;
|
||||||
period = iterator;
|
period = iterator;
|
||||||
led_period = period / 3;
|
led_a_period = period / 3;
|
||||||
|
led_b_period = period * 20 / 61;
|
||||||
iterator = 0;
|
iterator = 0;
|
||||||
rotations++;
|
rotations++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tacho_last = tacho_current;
|
tacho_last = tacho_current;
|
||||||
|
|
||||||
/* Emit strobe for LED */
|
/* Emit strobe for LED A */
|
||||||
led_counter--;
|
led_a_counter--;
|
||||||
if (led_counter < 12) {
|
if (led_a_counter < led_duration) {
|
||||||
digitalWrite(2, HIGH);
|
digitalWrite(2, HIGH);
|
||||||
if (!led_counter) {
|
if (!led_a_counter) {
|
||||||
led_counter = led_period;
|
led_a_counter = led_a_period;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
digitalWrite(2, LOW);
|
digitalWrite(2, LOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Emit strobe for LED B */
|
||||||
|
led_b_counter--;
|
||||||
|
if (led_b_counter < led_duration) {
|
||||||
|
digitalWrite(3, HIGH);
|
||||||
|
if (!led_b_counter) {
|
||||||
|
led_b_counter = led_b_period;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
digitalWrite(3, LOW);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user