![]() ![]() I've included a simple state diagram for the stop light to indicate how I built the state machine. The downside is it's more complicated and that tends to get in the way of understanding what's going on. The interrupt mode, which determines what pin action triggers an interrupt. I'll be happy to generate a more complicated program that demonstrates this. The function name of the interrupt service routine - this determines the code that gets run when the interrupt condition is met. Users (myself included) don't want to wait to input data - they want everything responsive, which can't happen with delay(). This type of thing is very important for a user interface. This is useful because it frees up the microprocessor to do other things. wakes up by pin change interrupt on digital 8 PB0. This program will echo everything that is typed in. It is possible to communicate between different devices using serial port such as two Arduino boards. This won't work with delay() AFAIK because the serial port only buffers one character at a time. ![]() Whatever you type into the Serial Monitor will get echoed to the serial port. Certain things do go on while the delay () function is controlling the Atmega chip, however, because the delay function does not disable interrupts. What's significant here is that the program is able to read the keyboard input at any time, not waiting until it's done with a delay. Once the light is triggered by hitting the 'Send' button on the Serial Monitor the program walks through its stop light sequence (prints which light is lit to the serial port). It is good practice to program nested interrupts in programs. I've generated a cheesy program to demonstrate where an interrupt is preferable to using delay(). A program must contain at least one interrupt in order to function correctly. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |