4

There is no cache, so you don't need to worry about that. All instructions are fetched direct from flash and executed straight away. There is, though, a 2-stage pipeline. That means that in one clock cycle an instruction is fetched from flash, and in the next clock cycle it's executed - and while that is being executed the next instruction is being fetched ...


3

The if statements (plural) you posted on GitHub are a lot different to the one you posted above. They contain a lot of of print commands to the LCD, so I think this is what is slowing your code down. It's a fair effort at nicely formatting the output on the display, but is rather convoluted. Here is a simplified version which writes to the LCD as little as ...


3

idk if the arduino stores the code for ever The code is saved in the flash memory, which is non-volatile. It does not lose its content during power cycles. Also, when looking at the time dimension, it holds the code over a very long time, though not for ever. The datasheet of the Atmega328p (the microcontroller in the Arduino Uno or Nano) states: ...


3

Technically, it is possible to start two PWM outputs at the exact same time on an Uno or Nano. If they are both controlled by the same timer, you just have to update the corresponding control register once with the relevant bits set to enable both channels. For example, you could start outputs 5 and 6 simultaneously, as both are on Timer 0: OCR0A = value; ...


3

Yes, the delay() will work, as will other methods based on the millis() counter. However, delay() will make it impossible to do something else in the meantime. Look up Blink without delay for an example of how to accomplish such a delay while being able to do other things in your code while waiting. Casting When dealing with large numbers such as your 24-...


3

delay() takes an unsigned long; I think what you do will work. When in doubt, you could always do something like this: for (int hours = 0; hours < 24; hours++) { for (int mins = 0; mins < 60; mins++) { for (int secs = 0; secs < 60; secs++) { delay(1000); } } } It will be wildly inaccurate ...


2

http://paulmurraycbr.github.io/ArduinoTheOOWay.html really helped me understand what was happening. i had some previous oop expierence with java, but i still have a hard time using multiple files vs writing more methods in one file


2

1 ns is a billionth of a second. A 1 gHz clock has a cycle time of 1 ns. If you have a timer that's able to count single clock pulses you'd need a 1 gHz clock to get to 1 ns resolution. for 10 ns, you'd need a 100 mHz clock. You won't get close to 10 ns resolution with an 8 mHz clocked device.


2

There is nothing you can do on the AVR processors that I know of, which can run on from a quite slow clock, and I think up to 24 MHz. Since your Uno / Leonardo / Micro run at 16 MHz that would be only an incremental speed improvement (to clock them at 24 MHz). Your idea of bit-banging is interesting, but in general bit-banging is a last resort when you need ...


1

I don’t think your fear is founded. Yes technically one motor starts after the other but the amount of time would be a few microseconds at most. For perspective it takes you about 200,000 microseconds to blink your eye. You will not be able to tell. They will appear to start at exactly the same time. You would need some very sophisticated high speed ...


1

What happens if the while condition fails? i.e. if millis() - time is greater than or equal to 20. Is this what you intended? If there's too much other stuff in the while loop, it may quit it and never re-enter it. loop() I've added a call to a function that prints debug information. unsigned long time = 0; void loop() { DebugMsgTime("loop() begin&...


1

loop() does not need any time and repeats permanently. lastButtonState is reading from previous loop run. As long as the button bounces, lastDebounceTime is updated. Only when the button has settled (either pressed or released), the condition ((millis() - lastDebounceTime) > debounceDelay) becomes true and the code is executed -> if buttonState (the ...


1

You could try enclosing the Uno in a temperature controlled "oven", say a plastic enclosure with a very low power heater (even a suitable resistor might do) and thermo sensor in with it. It should reduce some of the variation in the crystal frequency.


1

I used OOP with C++ on an Arduino Due in an open source project. Since I did not find any tutorila for the same the example might be helpful for You. https://github.com/eschlot/Box-Joint-Jig-Control W.r.t. the usability of OOP in embedded systems for scenarios like the above one there are plenty of good reasons to use OOP. A good example is the menu ...


Only top voted, non community-wiki answers of a minimum length are eligible