<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ca">
	<id>http://wiki.joanillo.org/index.php?action=history&amp;feed=atom&amp;title=Arduino%3A_programaci%C3%B3_dirigida_per_events</id>
	<title>Arduino: programació dirigida per events - Historial de revisió</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.joanillo.org/index.php?action=history&amp;feed=atom&amp;title=Arduino%3A_programaci%C3%B3_dirigida_per_events"/>
	<link rel="alternate" type="text/html" href="http://wiki.joanillo.org/index.php?title=Arduino:_programaci%C3%B3_dirigida_per_events&amp;action=history"/>
	<updated>2026-08-30T09:26:44Z</updated>
	<subtitle>Historial de revisió per a aquesta pàgina del wiki</subtitle>
	<generator>MediaWiki 1.34.2</generator>
	<entry>
		<id>http://wiki.joanillo.org/index.php?title=Arduino:_programaci%C3%B3_dirigida_per_events&amp;diff=250971&amp;oldid=prev</id>
		<title>Joan a 01:18, 11 des 2013</title>
		<link rel="alternate" type="text/html" href="http://wiki.joanillo.org/index.php?title=Arduino:_programaci%C3%B3_dirigida_per_events&amp;diff=250971&amp;oldid=prev"/>
		<updated>2013-12-11T01:18:49Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Pàgina nova&lt;/b&gt;&lt;/p&gt;&lt;div&gt;*http://blog.ardublock.com/2013/10/29/evaluating-of-event-driven-libraries-on-arduino/&lt;br /&gt;
*http://rain.aa.washington.edu/Tutorials/Robotics/Arduino/02%3A_Efficient_Arduino_Programming/01%3A_Event-Driven_Programming&lt;br /&gt;
*http://www.arduino.cc/en/Tutorial/BlinkWithoutDelay&lt;br /&gt;
&lt;br /&gt;
La manera més senzilla de fer-ho és com en el segon enllaç. Ara bé, aquesta és la manera senzilla de fer-ho: fer que el LED s'encengui i s'apagui cada segon, però no bloquejar tot el codi amb un delay.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
// constants won't change. Used here to&lt;br /&gt;
// set pin numbers:&lt;br /&gt;
const int ledPin =  13;      // the number of the LED pin&lt;br /&gt;
&lt;br /&gt;
// Variables will change:&lt;br /&gt;
int ledState = LOW;             // ledState used to set the LED&lt;br /&gt;
long previousMillis = 0;        // will store last time LED was updated&lt;br /&gt;
&lt;br /&gt;
// the follow variables is a long because the time, measured in miliseconds,&lt;br /&gt;
// will quickly become a bigger number than can be stored in an int.&lt;br /&gt;
long interval = 1000;           // interval at which to blink (milliseconds)&lt;br /&gt;
&lt;br /&gt;
void setup() {&lt;br /&gt;
  // set the digital pin as output:&lt;br /&gt;
  pinMode(ledPin, OUTPUT);      &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void loop()&lt;br /&gt;
{&lt;br /&gt;
  // here is where you'd put code that needs to be running all the time.&lt;br /&gt;
&lt;br /&gt;
  // check to see if it's time to blink the LED; that is, if the&lt;br /&gt;
  // difference between the current time and last time you blinked&lt;br /&gt;
  // the LED is bigger than the interval at which you want to&lt;br /&gt;
  // blink the LED.&lt;br /&gt;
  unsigned long currentMillis = millis();&lt;br /&gt;
 &lt;br /&gt;
  if(currentMillis - previousMillis &amp;gt; interval) {&lt;br /&gt;
    // save the last time you blinked the LED&lt;br /&gt;
    previousMillis = currentMillis;  &lt;br /&gt;
&lt;br /&gt;
    // if the LED is off turn it on and vice-versa:&lt;br /&gt;
    if (ledState == LOW)&lt;br /&gt;
      ledState = HIGH;&lt;br /&gt;
    else&lt;br /&gt;
      ledState = LOW;&lt;br /&gt;
&lt;br /&gt;
    // set the LED with the ledState of the variable:&lt;br /&gt;
    digitalWrite(ledPin, ledState);&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Una cosa més interessant és mirar altres exemples i llebreries que realment fan programació orientada als events, o programació orientada al pin (detectar l'event canvi d'estat en el pin).&lt;br /&gt;
&lt;br /&gt;
{{Autor}}, desembre 2013&lt;/div&gt;</summary>
		<author><name>Joan</name></author>
		
	</entry>
</feed>