Commit 028f8dd8 authored by Sam Guyer's avatar Sam Guyer
Browse files

Bug fix to motor control

Fixed the motor control — 0 is no power, 255 is full power. This change
was necessary for the PN2222 transistor used to do the actual voltage
control. Also changed some of the pins to match the Beetle arduino.
parent c771b0a9
......@@ -3,11 +3,11 @@
// -- Motor --------------------------------
#define MOTOR_PIN 12
#define MOTOR_PIN 9
// -- LED strip ----------------------------
#define LED_PIN 7
#define LED_PIN 10
// -- Number of LEDs in the strip
#define NUM_LEDS 6
......@@ -29,7 +29,7 @@ CRGB leds[NUM_LEDS];
// -- Button -------------------------------
#define BUTTON_PIN 4
#define BUTTON_PIN 11
MomentaryButton button(BUTTON_PIN);
// -----------------------------------------------
......@@ -47,7 +47,7 @@ void setup()
// -- Set up the pins
pinMode(LED_PIN, OUTPUT);
pinMode(MOTOR_PIN, OUTPUT);
analogWrite(MOTOR_PIN, 255);
analogWrite(MOTOR_PIN, 0);
button.init();
}
......@@ -117,7 +117,7 @@ void loop()
if (power > 1.0) power = 1.0;
// -- Motor speed
uint8_t motor_speed = 255 - (uint8_t) (power * 255.0);
uint8_t motor_speed = (uint8_t) (power * 255.0);
analogWrite(MOTOR_PIN, motor_speed);
// -- Go
......@@ -137,7 +137,7 @@ void loop()
power = 1.0 - power;
// -- Motor speed
uint8_t motor_speed = 255 - (uint8_t) (power * 255.0);
uint8_t motor_speed = (uint8_t) (power * 255.0);
analogWrite(MOTOR_PIN, motor_speed);
// -- Power down
......@@ -147,6 +147,7 @@ void loop()
leds[i] = CRGB::Black;
}
g_releaseTime = 0;
analogWrite(MOTOR_PIN, 0);
}
// -- Show the LEDS
FastLED.show();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment