Changes
Page history
Update Overview
authored
Mar 22, 2022
by
Brandon Cortez
Show whitespace changes
Inline
Side-by-side
Test-Stand/Overview.md
View page @
e149fb98
...
...
@@ -15,8 +15,9 @@ See here: https://git.ece.iastate.edu/danc/MicroCART/-/wikis/Test-Stand/Electron
# The Firmware
```
cpp
int
analogPin
=
A10
;
int
btnPin
=
9
;
int
analogPin
=
A7
;
int
btnPin
=
2
;
int
buttonState
=
0
;
int
val
=
0
;
double
scalar
=
0.3516
;
// 360/1024
...
...
@@ -27,22 +28,25 @@ void setup() {
// put your setup code here, to run once:
Serial
.
begin
(
9600
);
pinMode
(
btnPin
,
INPUT
);
pinMode
(
LED_BUILTIN
,
OUTPUT
);
homePosition
=
analogRead
(
analogPin
);
}
void
loop
()
{
// put your main code here, to run repeatedly:
if
(
digitalRead
(
btnPin
)){
buttonState
=
digitalRead
(
btnPin
);
if
(
buttonState
==
HIGH
){
digitalWrite
(
LED_BUILTIN
,
!
digitalRead
(
LED_BUILTIN
));
homePosition
=
analogRead
(
analogPin
);
}
val
=
analogRead
(
analogPin
);
double
actDeg
=
scalar
*
(
double
)
val
;
double
adjDeg
=
scalar
*
(
double
)
homePosition
;
//Serial.println("////////////////////////////////////////////");
Serial
.
println
(
actDeg
);
//Serial.println(homePosition);
//Serial.println(actDeg - adjDeg);
//Serial.println("////////////////////////////////////////////");
//delay(100);
double
absoluteDegrees
=
scalar
*
(
double
)
val
;
double
relativeDegrees
=
scalar
*
(
double
)
homePosition
;
double
displayPosition
=
absoluteDegrees
-
relativeDegrees
;
if
(
displayPosition
<
0
)
{
displayPosition
=
displayPosition
+
360
;
}
Serial
.
println
(
displayPosition
);
}
```
\ No newline at end of file