good. My application is ... like a weather station: the Arduino is full of sensors, and I want to take data and put it into Python and then into a database. And I want a data sample every fifteen miinutes.
Great question! By default all the digital pins are set as inputs, so it's not necessary here. However, on my better days I usually explicitly set them as inputs using the pinMode function, as i feel like it is more clear, so i should have done that here as well.
😉thank you for explaining the whole millis delay confusion from start to finish this will definitely help a lot of guys programming what they've always wanted. Can't wait for the next lesson!!!!
I am currently programming my arduino to move my camera to specific places and take pictures, a focus stacker. I am currently at over 1000 lines of code, is this a tight loop? :P
@@programmingelectronics Yeah, I usually try to write my Arduino code as branchless as I can, but I have no idea if it makes a difference or not. I suspect it does. Some compilers are smart enough to take your conditional logic and optimize it into branchless logic, but I have doubted the native Arduino compiler has been built to do that. But I just don't know at the end of the day.
and I ask you. are you normal ? You explain the difference between delay and millis and insert the for function. And how extensively you explain sorry but this video is Scary !!!!!
Not sure I agree with your definition of tight code. In general the specific length of time a loop spends is not really the main issue whether a loop is tight or not. A tight loop just has a non-blocking structure, so the time it takes to process is consistent with each run through the loop. When you introduce calls into a loop that will not provide consistent times to process than the tightness of your loop (and code) is compromised (think database calls, I/O reads, network processing calls, etc). I would say the example you give with the delay() function IS a tight loop (although generally not a goid programming practice due to the blocking). It will always stop your code for the set time so the loop time is consistent.
Really great explanation! I might mention that delay() could also be explained as its own loop that has nothing in it other than counting the time given to it. This fits well with your explanation of the actual loop.
to: Programming Electronics Academy I ask mysefl that the ATmega328 , 16 MHz crytal ; It will enforcement 16 million structrures per second so...16M/12 structrures to print the sentence "Ice Ice Baby" are 1,333,333 time per second ( mean Can It print 1,333,333 sentences "Ice Ice Baby" per second ?)
No. You created serial communication with 9600 changes per second, which in ideal world could be 9600 bit persecond speed. Even if i consider that 100% of data sended where actual words IceIcebaby, still, we got 10 letters(char) ,which are 10*8 =80 bits . 80/9600 this is what you idealy can send to screen, if you write drivers by yourself , without silence/parity check/stop bit and etc . Not all bits you send are part of data, some used for communication purposes. Moreover not really sure that every clock event instruction execute for every arduinos, are all of them "arm" based?