If you set a push button between D00 and GND and execute the code below, bStart
will only be 1.
Interrupts will also occur once every few times.
I would like bStart
to be reversed every time I press the button, but I would appreciate your advice.
void changeState() {//interrupt handler
bStart=~bStart;
Serial.println(bStart);
}
void setup() {
Serial.begin (115200);
pinMode(intPin,INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(intPin), changeState, FALLING);
}
I added a variable and loop function to the code above and tried to move it, but it seems to work as intended.
intbStart=0;
uint8_tintPin=0;//D00
void loop(){}
D00 and GND are jumpered together and bStart is toggle and displayed on the serial monitor.
If you look here,
https://developer.sony.com/develop/spresense/docs/arduino_developer_guide_ja.html#_attachinterrupt
It has a noise filter for three cycles of RTC (32.768 kHz) to prevent chattering against changes in pin numbers.
Therefore, interrupts may not be available for signal changes over steep pulses.
There may be a reason why the signal changes so fast.
© 2024 OneMinuteCode. All rights reserved.