Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
3 views

Programming Arduino (1) Pages 144

Uploaded by

axl1994
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Programming Arduino (1) Pages 144

Uploaded by

axl1994
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

significant bit or the most significant.

This should be one of the constants


MSBFIRST or LSBFIRST .
♦ The byte of data to be sent.

Interrupts
One of the things that tend to frustrate programmers used to “programming in
the large” is that the Arduino can do only one thing at a time. If you like to have
lots of threads of execution all running at the same time in your programs, then
you are out of luck. Although a few people have developed projects that can
execute multiple threads in this way, generally this capability is unnecessary for
the type of uses that an Arduino is normally put to. The closest an Arduino
usually gets to such execution is the use of interrupts.
Two of the pins on the Arduino Uno (D2 and D3) can have interrupts
attached to them. That is, these pins act as inputs that, if the pins receive a signal
in a specified way, the Arduino’s processor will suspend whatever it was doing
and run a function attached to that interrupt.
Sketch 7-04 blinks an LED, but then changes the blink period when an
interrupt is received. You can simulate an interrupt by connecting your wire
between pin D2 and GND and using the internal pull-up resistor to keep the
interrupt high most of the time.
//sketch 7-04

const int interruptPin = 2;

const int ledPin = 13;

int period = 500;

void setup()

You might also like