![]() With great respect to Stefan元8, I started reading this post and found it humorous. Maybe you or I would have written it differently? The home-grown Arduino Blink Without Delay is a good tutorial for some. Random Nerd has an article titled, "Why You Shouldn’t Always Use the Arduino Delay Function" here. Others want to understand but have not the background to appreciate the Big Picture. The implementation of delay, is just "SpinWheelsFor" and more knowledgeable programmers know that such a command often introduces negative consequences for the novice.Ī tremendous effort is made to assist an Op with a problem a great amount of knowledge transfer is often provided often unwanted by some who are just trying to complete their homework or trying to follow an Internet article/code. My point regarding the term myopic, is that changing the 'name' given to delay() changes nothing it is a perfectly good name for what happens, IMO. Discussions about how things work elsewhere have their use, but for solving problems in the here-and-now, that use is limited.īut it allows for better organized and more expressive code than the state machine approach that is common in the Arduino world.Īs Arduino is bolted onto C++, callbacks and timer interrupts and pin state interrupts also exist with Arduino: state-machine approach is generally easier for a novice to grasp which I suspect is why that methodology is often suggested. ![]() Nothing wrong with looking at the rest of the universe, of course. I wouldn't exactly call this matter "myopic" - this is the Arduino forum and there's nothing wrong with having discussions that are limited in scope to the Arduino ecosystem. Personally I think that this programming model is not necessarily intuitive, but it allows for better organized and more expressive code than the state machine approach that is common in the Arduino world.īut be that as it may - most people in this forum use the Arduino API, and I doubt the Arduino folks are going to pivot their well-established API into a completely different programming model and force all their users to completely re-learn the platform. This isolates your "state transitions" from their actual causes - it doesn't matter if you want a thing to happen in 1000ms, or if you want a thing to happen when a button is pressed, or if you want a thing to happen if something goes wrong, you simply attach the thing you want to happen to the event which should trigger it. All of this seems myopic, as no consideration is being given beyond current one-cpu microcontrollers and state-machine like programming.Įven in "one-cpu" environments like JavaScript and node.js (which generally run single-threaded no matter how many cores your physical CPU has), things are very different than they are in the Arduino system because your application is driven by events in the form of callbacks, promises, or observables.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |