Update Overview authored by Brandon Cortez's avatar Brandon Cortez
...@@ -15,8 +15,9 @@ See here: https://git.ece.iastate.edu/danc/MicroCART/-/wikis/Test-Stand/Electron ...@@ -15,8 +15,9 @@ See here: https://git.ece.iastate.edu/danc/MicroCART/-/wikis/Test-Stand/Electron
# The Firmware # The Firmware
``` cpp ``` cpp
int analogPin = A10; int analogPin = A7;
int btnPin = 9; int btnPin = 2;
int buttonState = 0;
int val = 0; int val = 0;
double scalar = 0.3516; // 360/1024 double scalar = 0.3516; // 360/1024
...@@ -27,22 +28,25 @@ void setup() { ...@@ -27,22 +28,25 @@ void setup() {
// put your setup code here, to run once: // put your setup code here, to run once:
Serial.begin(9600); Serial.begin(9600);
pinMode(btnPin, INPUT); pinMode(btnPin, INPUT);
pinMode(LED_BUILTIN, OUTPUT);
homePosition = analogRead(analogPin); homePosition = analogRead(analogPin);
} }
void loop() { void loop() {
// put your main code here, to run repeatedly: // 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); homePosition = analogRead(analogPin);
} }
val = analogRead(analogPin); val = analogRead(analogPin);
double actDeg = scalar * (double) val; double absoluteDegrees = scalar * (double) val;
double adjDeg = scalar * (double) homePosition; double relativeDegrees = scalar * (double) homePosition;
//Serial.println("////////////////////////////////////////////"); double displayPosition = absoluteDegrees - relativeDegrees;
Serial.println(actDeg); if(displayPosition < 0) {
//Serial.println(homePosition); displayPosition = displayPosition + 360;
//Serial.println(actDeg - adjDeg); }
//Serial.println("////////////////////////////////////////////"); Serial.println(displayPosition);
//delay(100);
} }
``` ```
\ No newline at end of file