Accelerometer readings based on switch setting , stops prematurely #12250
-
I have written the following code for the Raspberry Pico which in core0 will run accelerometer readings. Based on a switch state connected to the Pico, the accelerometer readings will light a red LED if specific treshold values are exceeded. The script works fine when the switch_state == 0 , but setting the switch_state == 1 causes the script to only take one accelerometer reading and then terminating the script as the example below 0.02770996 0.04833984 0.9343262 Can anyone help me explain why switch_state == 1 does not react similar to switch_state == 1 ? Code is copied in below. Any help I can get is highly appreciated :-) Kind regards
` |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Why do the limits change for accel values in the test for switch_state == 1? After |
Beta Was this translation helpful? Give feedback.
-
I would suggest that in state 1 the condition Incidentally initialising the MPU in a loop is unnecessary. Do it once before the start of the loop. |
Beta Was this translation helpful? Give feedback.
-
Thank you very much for your suggestions. I really appreciated the fast response to my question. Have a wonderful day ! |
Beta Was this translation helpful? Give feedback.
I would suggest that in state 1 the condition
1.70 < accelz < 2.30
is not being met, causing thebreak
instruction to be executed. The loop will then quit.Incidentally initialising the MPU in a loop is unnecessary. Do it once before the start of the loop.