fixes
This commit is contained in:
parent
b952e9fe1e
commit
bae69f19c4
36
src/main.cpp
36
src/main.cpp
@ -56,6 +56,9 @@ void setup() {
|
||||
void loop() {
|
||||
// Calculate how long no data bucket was received
|
||||
if (DMXSerial.noDataSince() < 5000) {
|
||||
if (DMXSerial.read(DMX_CHANNEL + 7) > 0) {
|
||||
pidPwm = DMXSerial.read(DMX_CHANNEL + 7);
|
||||
} else {
|
||||
|
||||
// read recent DMX values and set pwm levels
|
||||
// pidGain = 0.0001 + (0.002 * (DMXSerial.read(DMX_CHANNEL + 1) / 255));
|
||||
@ -75,26 +78,21 @@ void loop() {
|
||||
// if (pidPwm > 255) pidPwm = 255;
|
||||
// if (pidPwm < -255) pidPwm = -255;
|
||||
|
||||
if (abs(pidPwm > 150)) {
|
||||
digitalWrite(R_EN_PIN, 1);
|
||||
digitalWrite(L_EN_PIN, 1);
|
||||
if (pidPwm > 0) {
|
||||
analogWrite(RPWM_PIN, 0);
|
||||
analogWrite(LPWM_PIN, pidPwm);
|
||||
|
||||
analogWrite(5, 0);
|
||||
analogWrite(6, pidPwm);
|
||||
} else {
|
||||
analogWrite(LPWM_PIN, 0);
|
||||
analogWrite(RPWM_PIN, -pidPwm);
|
||||
|
||||
analogWrite(6, 0);
|
||||
analogWrite(5, -pidPwm);
|
||||
}
|
||||
} else {
|
||||
digitalWrite(R_EN_PIN, 0);
|
||||
digitalWrite(L_EN_PIN, 0);
|
||||
}
|
||||
|
||||
if (pidPwm > 0) {
|
||||
analogWrite(RPWM_PIN, 0);
|
||||
analogWrite(LPWM_PIN, pidPwm);
|
||||
|
||||
analogWrite(5, 0);
|
||||
analogWrite(6, pidPwm);
|
||||
} else {
|
||||
analogWrite(LPWM_PIN, 0);
|
||||
analogWrite(RPWM_PIN, -pidPwm);
|
||||
|
||||
analogWrite(6, 0);
|
||||
analogWrite(5, -pidPwm);
|
||||
}
|
||||
|
||||
} else {
|
||||
digitalWrite(R_EN_PIN, 0);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user