<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ca">
	<id>https://www.binefa.com/index.php?action=history&amp;feed=atom&amp;title=Rebots_i_detecci%C3%B3_de_flancs_a_Arduino</id>
	<title>Rebots i detecció de flancs a Arduino - Historial de revisió</title>
	<link rel="self" type="application/atom+xml" href="https://www.binefa.com/index.php?action=history&amp;feed=atom&amp;title=Rebots_i_detecci%C3%B3_de_flancs_a_Arduino"/>
	<link rel="alternate" type="text/html" href="https://www.binefa.com/index.php?title=Rebots_i_detecci%C3%B3_de_flancs_a_Arduino&amp;action=history"/>
	<updated>2026-04-24T14:57:49Z</updated>
	<subtitle>Historial de revisió per a aquesta pàgina del wiki</subtitle>
	<generator>MediaWiki 1.33.0</generator>
	<entry>
		<id>https://www.binefa.com/index.php?title=Rebots_i_detecci%C3%B3_de_flancs_a_Arduino&amp;diff=12009&amp;oldid=prev</id>
		<title>Jordi Binefa: /* El Rebot (Debouncing) */</title>
		<link rel="alternate" type="text/html" href="https://www.binefa.com/index.php?title=Rebots_i_detecci%C3%B3_de_flancs_a_Arduino&amp;diff=12009&amp;oldid=prev"/>
		<updated>2026-03-09T16:04:15Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;El Rebot (Debouncing)&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ca&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Versió més antiga&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revisió del 16:04, 9 març 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l43&quot; &gt;Línia 43:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Línia 43:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Els botons són mecànics. Quan prems, dues làmines de metall xoquen i, a nivell microscòpic, &amp;quot;reboten&amp;quot; durant uns mil·lisegons. L'Arduino és tan ràpid que llegeix aquests rebots com si haguessis premut el botó 10 vegades seguides.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Els botons són mecànics. Quan prems, dues làmines de metall xoquen i, a nivell microscòpic, &amp;quot;reboten&amp;quot; durant uns mil·lisegons. L'Arduino és tan ràpid que llegeix aquests rebots com si haguessis premut el botó 10 vegades seguides.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Solució: El ''delay(50);'' fa que l'Arduino &amp;quot;es quedi sord&amp;quot; durant 50 ms després de detectar el primer flanc, ignorant així tots els rebots elèctrics posteriors.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;Solució&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;'''&lt;/ins&gt;: El ''delay(50);'' fa que l'Arduino &amp;quot;es quedi sord&amp;quot; durant 50 ms després de detectar el primer flanc, ignorant així tots els rebots elèctrics posteriors.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wiki_binefa_com:diff::1.12:old-12008:rev-12009 --&gt;
&lt;/table&gt;</summary>
		<author><name>Jordi Binefa</name></author>
		
	</entry>
	<entry>
		<id>https://www.binefa.com/index.php?title=Rebots_i_detecci%C3%B3_de_flancs_a_Arduino&amp;diff=12008&amp;oldid=prev</id>
		<title>Jordi Binefa: /* Codi d'exemple */</title>
		<link rel="alternate" type="text/html" href="https://www.binefa.com/index.php?title=Rebots_i_detecci%C3%B3_de_flancs_a_Arduino&amp;diff=12008&amp;oldid=prev"/>
		<updated>2026-03-09T16:03:42Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Codi d&amp;#039;exemple&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;ca&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Versió més antiga&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revisió del 16:03, 9 març 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l30&quot; &gt;Línia 30:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Línia 30:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;      delay(50);  &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;      delay(50);  &lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;    }&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;    }&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt; &lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt; &lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;    // Desem l'estat actual per a la següent iteració&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;    // Desem l'estat actual per a la següent iteració&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;    ultimEstatBoto = estatActualBoto;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;    ultimEstatBoto = estatActualBoto;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wiki_binefa_com:diff::1.12:old-12007:rev-12008 --&gt;
&lt;/table&gt;</summary>
		<author><name>Jordi Binefa</name></author>
		
	</entry>
	<entry>
		<id>https://www.binefa.com/index.php?title=Rebots_i_detecci%C3%B3_de_flancs_a_Arduino&amp;diff=12007&amp;oldid=prev</id>
		<title>Jordi Binefa: Es crea la pàgina amb «= Codi d'exemple =  // Definició de pins  const int pinBoto = 2;  const int pinLed = 13;    // Variables d'estat  bool estatLed = LOW;       // Estat actual del LED...».</title>
		<link rel="alternate" type="text/html" href="https://www.binefa.com/index.php?title=Rebots_i_detecci%C3%B3_de_flancs_a_Arduino&amp;diff=12007&amp;oldid=prev"/>
		<updated>2026-03-09T16:03:27Z</updated>

		<summary type="html">&lt;p&gt;Es crea la pàgina amb «= Codi d&amp;#039;exemple =  // Definició de pins  const int pinBoto = 2;  const int pinLed = 13;    // Variables d&amp;#039;estat  bool estatLed = LOW;       // Estat actual del LED...».&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Pàgina nova&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Codi d'exemple =&lt;br /&gt;
 // Definició de pins&lt;br /&gt;
 const int pinBoto = 2;&lt;br /&gt;
 const int pinLed = 13;&lt;br /&gt;
 &lt;br /&gt;
 // Variables d'estat&lt;br /&gt;
 bool estatLed = LOW;       // Estat actual del LED&lt;br /&gt;
 bool ultimEstatBoto = HIGH; // Estat del botó en el cicle anterior (comença en HIGH pel pull-up)&lt;br /&gt;
 &lt;br /&gt;
 void setup() {&lt;br /&gt;
   pinMode(pinBoto, INPUT);  // Entrada amb pull-up físic&lt;br /&gt;
   pinMode(pinLed, OUTPUT);  // El LED de la placa&lt;br /&gt;
   digitalWrite(pinLed, estatLed);&lt;br /&gt;
 }&lt;br /&gt;
 &lt;br /&gt;
 void loop() {&lt;br /&gt;
   // 1. Llegim l'estat actual del botó&lt;br /&gt;
   bool estatActualBoto = digitalRead(pinBoto);&lt;br /&gt;
 &lt;br /&gt;
   // 2. DETECCIÓ DE FLANC (Edge Detection)&lt;br /&gt;
   // Comprovem si l'estat ha canviat de HIGH a LOW (pulsació)&lt;br /&gt;
   if (ultimEstatBoto == HIGH &amp;amp;&amp;amp; estatActualBoto == LOW) {&lt;br /&gt;
    &lt;br /&gt;
     // 3. ACCIÓ: Canviem l'estat del LED (Toggle)&lt;br /&gt;
     estatLed = !estatLed;&lt;br /&gt;
     digitalWrite(pinLed, estatLed);&lt;br /&gt;
 &lt;br /&gt;
     // 4. DEBOUNCING (Antirebots)&lt;br /&gt;
     // Esperem un instant perquè les vibracions metàl·liques del polsador s'aturin&lt;br /&gt;
     delay(50); &lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   // Desem l'estat actual per a la següent iteració&lt;br /&gt;
   ultimEstatBoto = estatActualBoto;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
= '''El Flanc''' (''Edge Detection'') =&lt;br /&gt;
Si només fessis un ''if (digitalRead(2) == LOW)'', el LED s'encendria i s'apagaria milers de vegades per segon mentre tinguessis el dit premut (perquè el bucle ''loop'' és molt ràpid).&lt;br /&gt;
&lt;br /&gt;
'''Detecció de flanc''': Només actuem quan l'estat canvia. En aquest cas, busquem el '''flanc de baixada''' (de 1 a 0), que és el moment exacte en què prems el botó.&lt;br /&gt;
&lt;br /&gt;
= '''El Rebot''' (''Debouncing'') = &lt;br /&gt;
Els botons són mecànics. Quan prems, dues làmines de metall xoquen i, a nivell microscòpic, &amp;quot;reboten&amp;quot; durant uns mil·lisegons. L'Arduino és tan ràpid que llegeix aquests rebots com si haguessis premut el botó 10 vegades seguides.&lt;br /&gt;
&lt;br /&gt;
Solució: El ''delay(50);'' fa que l'Arduino &amp;quot;es quedi sord&amp;quot; durant 50 ms després de detectar el primer flanc, ignorant així tots els rebots elèctrics posteriors.&lt;/div&gt;</summary>
		<author><name>Jordi Binefa</name></author>
		
	</entry>
</feed>