Changes
Page history
Update Overview
authored
Mar 29, 2022
by
Reid Schneyer
Show whitespace changes
Inline
Side-by-side
Test-Stand/Overview.md
View page @
5f6fd0b9
...
...
@@ -18,6 +18,9 @@ See here: https://git.ece.iastate.edu/danc/MicroCART/-/wikis/Test-Stand/Electron
const
int
DATA_PIN
=
A7
;
const
int
BUTTON_PIN
=
2
;
int
buttonState
=
0
;
const
boolean
NO_HANDSHAKE
=
false
;
const
int
SEND_CODE
=
65
;
int
incomingByte
=
0
;
int
val
=
0
;
const
double
TEN_BIT_SCALAR
=
0.3516
;
// 360/1024
...
...
@@ -41,6 +44,13 @@ boolean buttonActive = false;
boolean
longPressActive
=
false
;
boolean
isInPositionMode
=
true
;
void
serialFlush
()
{
while
(
Serial
.
available
()
>
0
)
{
char
t
=
Serial
.
read
();
}
}
void
setup
()
{
// put your setup code here, to run once:
Serial
.
begin
(
9600
);
...
...
@@ -85,18 +95,28 @@ void loop() {
double
relativeDegrees
=
TEN_BIT_SCALAR
*
(
double
)
homePosition
;
double
displayPosition
=
absoluteDegrees
-
relativeDegrees
;
displayPosition
+=
(
displayPosition
<
0
)
?
(
360
)
:
(
0
);
if
(
NO_HANDSHAKE
)
{
Serial
.
println
(
displayPosition
);
}
else
if
(
Serial
.
available
()
>
0
&&
Serial
.
read
()
==
SEND_CODE
)
{
Serial
.
println
(
"DEBUG"
);
Serial
.
println
(
displayPosition
);
}
}
else
{
// We're in rate mode
deltaTime
=
currTime
-
lastTime
;
deltaReading
=
currReading
-
lastReading
;
rate
=
1000
*
((
TEN_BIT_SCALAR
*
deltaReading
)
/
(
deltaTime
));
Serial
.
println
(
rate
);
}
delay
(
100
);
}
// Reset vars for next cycle
lastTime
=
currTime
;
lastReading
=
currReading
;
}
```
\ No newline at end of file