Rudder electronics cover and arduino code

This commit is contained in:
Steve Caster 2024-11-11 11:32:31 +01:00
parent 7bec93ee58
commit 2464c3f8c0
5 changed files with 80 additions and 0 deletions

View file

@ -0,0 +1,80 @@
/*
Button
Turns on and off a light emitting diode(LED) connected to digital pin 13,
when pressing a pushbutton attached to pin 2.
The circuit:
- LED attached from pin 13 to ground through 220 ohm resistor
- pushbutton attached to pin 2 from +5V
- 10K resistor attached to pin 2 from ground
- Note: on most Arduinos there is already an LED on the board
attached to pin 13.
created 2005
by DojoDave <http://www.0j0.org>
modified 30 Aug 2011
by Tom Igoe
This example code is in the public domain.
https://www.arduino.cc/en/Tutorial/BuiltInExamples/Button
*/
#include <AccelStepper.h>
// constants won't change. They're used here to set pin numbers:
const int buttonPin = 14; // the number of the pushbutton pin
const int buttonPin2 = 15;
const int ledPin = 13; // the number of the LED pin
int check_stopped = 1;
AccelStepper stepper; // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5
// variables will change:
int buttonState1 = 0; // variable for reading the pushbutton status
int buttonState2 = 0;
void setup() {
// initialize the LED pin as an output:
Serial.begin(115200);
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT_PULLUP);
pinMode(buttonPin2, INPUT_PULLUP);
stepper.setMaxSpeed(1000);
}
void loop() {
// read the state of the pushbutton value:
buttonState1 = digitalRead(buttonPin);
buttonState2 = digitalRead(buttonPin2);
// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (buttonState1 ==LOW && buttonState2 == LOW) {
Serial.println("Both pressed");
}
else if (buttonState1 == LOW && buttonState2 == HIGH) {
//Serial.println("B2 pressed");
//Serial.println(check_stopped);
stepper.enableOutputs();
check_stopped = 1;
stepper.setSpeed(1000);
stepper.runSpeed();
}
else if (buttonState1 == HIGH && buttonState2 == LOW) {
check_stopped = 1;
//Serial.println("B1 pressed");
//Serial.println(check_stopped);
stepper.enableOutputs();
stepper.setSpeed(-1000);
stepper.runSpeed();
}
else if (stepper.isRunning()) {
stepper.stop();
stepper.disableOutputs();
stepper.enableOutputs();
}
}

Binary file not shown.

Binary file not shown.

BIN
Rudders/Mounts.FCStd Normal file

Binary file not shown.

Binary file not shown.