Go Down

Topic: Leonardo: Sketch works in one board, but not in another.  (Read 160 times) previous topic - next topic

Jushil

Hi!

Has anyone encountered anything similar to this strange problem when sketch is working well in one Leonardo board, but not in another?

I have this simple "jog wheel" script that uses rotary encoder to act as keyboard left, right and spacebar buttons. First board I used worked flawlessly, but then when I tried uploading the sketch to second and third board only spacebar was working.
I've spent too many hours trying to solve this without any luck.

I'm running Linux Manjaro on fairly new Hp laptop if that has anything to do with this.


Thanks in advance,


 - Jussi

ballscrewbob

Could you take a few moments to Learn How To Use The Forum.
It will help you get the best out of the forum in the future.

Posting tips.
  • Your OS and version can be valuable information, please include it along with extra security you are using.
  • Always list the version of the IDE you are using and the board version if applicable.
  • How to insert an image into your post. ( Thanks Robin2 )
  • Add your sketch where applicable but please use CODE TAGS ( </> )
  • Add a SCHEMATIC were needed even if it is hand drawn
  • Add working links to any specific hardware as needed (NOT links to similar items)
  • Remember that the people trying to help cannot see your problem so give as much information as you can
It may not be the answer you were looking for but its the one I am giving based on either experience, educated guess, google or the fact that you gave nothing to go with in the first place so I used my wonky crystal ball.

sterretje

Bad contacts in wiring? Incorrectly wired?
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

pert

Try adding some Serial.println() calls to strategic locations in your code, then run it with Serial Monitor open. That will allow you to see what it happening in your program. Knowing whether the problem is caused by not getting readings from the encoder, or whether it is getting the readings and sending the key presses, will be very helpful in troubleshooting.

Jushil

Thanks for your replies!

I'm using:
- Linux Manjaro (Kernel 5.4.6-2), KDE Plasma 5.17.4
- IDE version 1.8.10


Bad contacts in wiring? Incorrectly wired?
Wired correctly, double checked.
Tested with several rotary encoders and two different boards so I don't think that would be the issue.

Try adding some Serial.println() calls to strategic locations in your code, then run it with Serial Monitor open. That will allow you to see what it happening in your program. Knowing whether the problem is caused by not getting readings from the encoder, or whether it is getting the readings and sending the key presses, will be very helpful in troubleshooting.
Tried that and it seemed like that the code was not going to seperate "left" and "right" functions at all.
I modified the code and now it's somewhat working.

The main question is that how the sketch works in one board but not in the other two?

pert

Tried that and it seemed like that the code was not going to seperate "left" and "right" functions at all.
It's not clear to me what you mean by that.

The main question is that how the sketch works in one board but not in the other two?
We could probably answer that question if you provide a detailed description of what you observed from the Serial output and what change you made to the code to fix it.

Jushil

It's not clear to me what you mean by that.
We could probably answer that question if you provide a detailed description of what you observed from the Serial output and what change you made to the code to fix it.
You are missing the point. I can always make a workaround to the code, that's not problem.
I removed some variables and "if" statement that checks those variables.
The original code worked in one board, but not in the other two.

The point was that if sketch works in one board then it should work in all identical boards. Right?
I was just wondering if I'm missing something here (if it has something to do with how linux detects boards or something similar, etc,.. )

pert

The point was that if sketch works in one board then it should work in all identical boards. Right?
Clearly not. We have no way of knowing if each is truly identical. It might be that you have updated some software after the time you uploaded to the first board and that changed the behavior. It might be that you have a floating pin that just happens to be steered the right way on one board but not the others.

Look, we don't have your board in front of us. We are trying to help you remotely and so the only information we have to go on is the very little you have provided. The more relevant information you can give us, the more likely it is we can help you. Presumably, you came here hoping to get help with your problem. So when someone who is trying to help you asks for information, why not just provide the information?

Jushil

Clearly not. We have no way of knowing if each is truly identical. It might be that you have updated some software after the time you uploaded to the first board and that changed the behavior. It might be that you have a floating pin that just happens to be steered the right way on one board but not the others.

Look, we don't have your board in front of us. We are trying to help you remotely and so the only information we have to go on is the very little you have provided. The more relevant information you can give us, the more likely it is we can help you. Presumably, you came here hoping to get help with your problem. So when someone who is trying to help you asks for information, why not just provide the information?
Yeah, I get that you are trying to help and I really appreciate that.
I came here more out of curiosity (if someone has encountered this kind of thing before), rather than need of help (although it would be nice to fix it).

It was the same day I tried uploading the code to the other two boards so it's not updated software that causes it. Floating pin sounds more likely, I'll test that when I come back from work.

Go Up