I'm using Arduino MEGA 2560 with Simulink through the Simulink Support Package for Arduino Hardware and a joystick ARD-358
I have a problem when reading the state of the button of my joystick with the block Digital Input in Simulink. It does not read the digital signal, I always get the same value (0) wether I'm pressing the button or not.
This does not happen when using the following code in Arduino (the software).
int buttonPin = 53;
int buttonState = 0;
void setup() {
Serial.begin(9600);
pinMode(buttonPin, INPUT_PULLUP);
}
void loop() {
buttonState = digitalRead(buttonPin);
Serial.print(" | Button: ");
Serial.println(buttonState);
delay(100);
}
With this code I do get an accurate lecture, so we can rule out hardware damage.
The only difference I see between the Simulink diagram and the Arduino code is the section void setup, in which the pinMode is defined. In the Command Window in MATLAB I can use a similar command, configurePin, but I do not know how to use it in simulink.
I'd very much appreciate your help.