change this arduino code to matlab one

1 view (last 30 days)
john white
john white on 27 May 2019
Hi
is it possible to change this arduino code to the matlab code please thanks
#define outputA 6
#define outputB 7
int counter = 0;
int aState;
int aLastState;
void setup() {
pinMode (outputA, INPUT);
pinMode (outputB, INPUT);
Serial.begin(9600);
aLastState = digitalRead(outputA);
}
void loop() {
aState = digitalRead(outputA);
if (aState != aLastState) {
if (digitalRead(outputB) != aState) {
counter ++;
} else {
counter --;
}
Serial.print("Position: ");
Serial.println(counter);
}
aLastState = aState;
}

Answers (0)

Categories

Find more on MATLAB Support Package for Arduino Hardware in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!