Browse code

Rudder electronics cover and arduino code

Steve caster authored on11/11/2024 10:32:31
Showing5 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,80 @@
1
+/*
2
+  Button
3
+
4
+  Turns on and off a light emitting diode(LED) connected to digital pin 13,
5
+  when pressing a pushbutton attached to pin 2.
6
+
7
+  The circuit:
8
+  - LED attached from pin 13 to ground through 220 ohm resistor
9
+  - pushbutton attached to pin 2 from +5V
10
+  - 10K resistor attached to pin 2 from ground
11
+
12
+  - Note: on most Arduinos there is already an LED on the board
13
+    attached to pin 13.
14
+
15
+  created 2005
16
+  by DojoDave <http://www.0j0.org>
17
+  modified 30 Aug 2011
18
+  by Tom Igoe
19
+
20
+  This example code is in the public domain.
21
+
22
+  https://www.arduino.cc/en/Tutorial/BuiltInExamples/Button
23
+*/
24
+
25
+#include <AccelStepper.h>
26
+
27
+// constants won't change. They're used here to set pin numbers:
28
+const int buttonPin = 14;     // the number of the pushbutton pin
29
+const int buttonPin2 = 15;
30
+const int ledPin =  13;      // the number of the LED pin
31
+int check_stopped = 1;
32
+
33
+AccelStepper stepper; // Defaults to AccelStepper::FULL4WIRE (4 pins) on 2, 3, 4, 5
34
+
35
+// variables will change:
36
+int buttonState1 = 0;         // variable for reading the pushbutton status
37
+int buttonState2 = 0; 
38
+
39
+void setup() {
40
+  // initialize the LED pin as an output:
41
+  Serial.begin(115200);
42
+  pinMode(ledPin, OUTPUT);
43
+  // initialize the pushbutton pin as an input:
44
+  pinMode(buttonPin, INPUT_PULLUP);
45
+  pinMode(buttonPin2, INPUT_PULLUP);
46
+  stepper.setMaxSpeed(1000);
47
+}
48
+
49
+void loop() {
50
+  // read the state of the pushbutton value:
51
+  buttonState1 = digitalRead(buttonPin);
52
+  buttonState2 = digitalRead(buttonPin2);
53
+ 
54
+
55
+  // check if the pushbutton is pressed. If it is, the buttonState is HIGH:
56
+  if (buttonState1 ==LOW && buttonState2 == LOW) {
57
+    Serial.println("Both pressed");
58
+  }
59
+  else if (buttonState1 == LOW && buttonState2 == HIGH) {
60
+    //Serial.println("B2 pressed");
61
+    //Serial.println(check_stopped);
62
+    stepper.enableOutputs();
63
+    check_stopped = 1;
64
+    stepper.setSpeed(1000);
65
+    stepper.runSpeed();
66
+  }
67
+  else if (buttonState1 == HIGH && buttonState2 == LOW) {
68
+    check_stopped = 1;
69
+    //Serial.println("B1 pressed");
70
+    //Serial.println(check_stopped);
71
+    stepper.enableOutputs();
72
+    stepper.setSpeed(-1000);
73
+    stepper.runSpeed();
74
+  } 
75
+  else if (stepper.isRunning()) {
76
+        stepper.stop();
77
+        stepper.disableOutputs();
78
+         stepper.enableOutputs();
79
+  }
80
+}
0 81
new file mode 100644
1 82
Binary files /dev/null and b/External Parts/MicroPro_base.stl differ
2 83
new file mode 100644
3 84
Binary files /dev/null and b/Rudders/Electronics_Cover.FCStd differ
4 85
new file mode 100644
5 86
Binary files /dev/null and b/Rudders/Mounts.FCStd differ
6 87
new file mode 100644
7 88
Binary files /dev/null and b/Rudders/bearing Holder.FCStd differ