Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Aeleron
Arduino based control for my aircraft wing project
# Rack and Pinion
Arduino based control for my rack and pinion project, branched from general servo control
8 changes: 4 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#define ZERO_OFFSET 90
#define BUTTON_PIN 9
//Servo travel from onshape assembly (https://cad.onshape.com/documents/d18afc04477c0a37ba3a6c4c/w/296bb2347621a61e29efeed9/e/c0daab103472e3648c63e07d?renderMode=0&uiState=67d52d3223160a63ec30cd7a)
#define MAXIMUM_ELEVATION 30
#define MAXIMUM_DEPRESSION -55
#define MAXIMUM_TRAVEL 90
#define MINIMUM_TRAVEL -90
#define POT1_PIN A0

Servo servo1;
Expand All @@ -25,15 +25,15 @@ void setup() {
void loop() {
bool button = digitalRead(BUTTON_PIN);
servo1.write(servo_angle + ZERO_OFFSET);
Serial.println(servo_angle + ZERO_OFFSET);
if (neutral_mode){
servo_angle = 0;
if (!button){
neutral_mode = false;
}
}
if (!neutral_mode){
int desired_angle = map(analogRead(POT1_PIN), 0, 1023, MAXIMUM_DEPRESSION, MAXIMUM_ELEVATION);
Serial.println(desired_angle);
int desired_angle = map(analogRead(POT1_PIN), 0, 1023, MINIMUM_TRAVEL, MAXIMUM_TRAVEL);
if (abs(servo_angle - desired_angle) > ANGLE_TOLERANCE){
servo_angle = desired_angle;
}
Expand Down