You are not logged in. Your edit will be placed in a queue until it is peer reviewed.
We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
- You need to download the data sheet of the AVR and look up the port registers. Then you can access (read or write) all bits of a port with a single instruction. You will need to change your keyboard scanning algorithm accordingly. -- Having said this, I'm not sure that the Arduino libraries don't have methods to do this already.the busybee– the busybee2020-08-19 07:26:56 +00:00Commented Aug 19, 2020 at 7:26
- 1I do not think that direct port access increases the speed of your program remarkably. If you natively read a PORT you have to store the value in a CPU register and then check its bits in the loop. There is a difference in reading a IO register compared to an internal CPU register, but its not that much compared to the time you need to send the midi note. And that's limited to the midi speed. (Wich is 31250 bps, as far as i know - not 38400 as I saw in your code). But if the receiver understands, it's OK ;-). So, I would say the midi speed is he bottleneck not the keyboard scanner algorithm.Peter Paul Kiefer– Peter Paul Kiefer2020-08-19 09:04:07 +00:00Commented Aug 19, 2020 at 9:04
- 1Ah, if you don't need any wise ( dumb ;-) ) talk. Here is a link that answers yout question. So you can decide whether it is worth it, to change your program. arduino.cc/en/Reference/PortManipulationPeter Paul Kiefer– Peter Paul Kiefer2020-08-19 09:18:49 +00:00Commented Aug 19, 2020 at 9:18
- I doubt if you gain anything with it, as Serial will be the bottleneck. But if you must, I'd suggest something like the digitalWriteFast library.Gerben– Gerben2020-08-19 14:48:01 +00:00Commented Aug 19, 2020 at 14:48
Add a comment |
How to Edit
- Correct minor typos or mistakes
- Clarify meaning without changing it
- Add related resources or links
- Always respect the author’s intent
- Don’t use edits to reply to the author
How to Format
- create code fences with backticks ` or tildes ~ ```
like so
``` - add language identifier to highlight code ```python
def function(foo):
print(foo)
``` - put returns between paragraphs
- for linebreak add 2 spaces at end
- _italic_ or **bold**
- indent code by 4 spaces
- backtick escapes
`like _so_` - quote by placing > at start of line
- to make links (use https whenever possible) <https://example.com>[example](https://example.com)<a href="https://example.com">example</a>
How to Tag
A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
- complete the sentence: my question is about...
- use tags that describe things or concepts that are essential, not incidental to your question
- favor using existing popular tags
- read the descriptions that appear below the tag
If your question is primarily about a topic for which you can't find a tag:
- combine multiple words into single-words with hyphens (e.g. arduino-uno), up to a maximum of 35 characters
- creating new tags is a privilege; if you can't yet create a tag you need, then post this question without it, then ask the community to create it for you
lang-cpp