(Annulation des modifications 1206 de Sgiraud (discussion)) |
|||
Ligne 110 : | Ligne 110 : | ||
{{Tuto Step | {{Tuto Step | ||
|Step_Title=Le Code | |Step_Title=Le Code | ||
− | |Step_Content= | + | |Step_Content=[[<pre style='color:#000000;background:#ffffff;'><span style='color:#004a43; '>#</span><span style='color:#004a43; '>define</span><span style='color:#004a43; '> data 2</span> |
− | + | <span style='color:#004a43; '>#</span><span style='color:#004a43; '>define</span><span style='color:#004a43; '> clock 3 </span><span style='color:#696969; '>//D PWM</span> | |
− | |||
− | |||
− | |||
− | + | <span style='color:#696969; '>/*</span> | |
− | // | + | <span style='color:#696969; '> * CHILLER DISP Rev 0.0</span> |
+ | <span style='color:#696969; '>  LED Display: ___</span> | ||
+ | <span style='color:#696969; '>                 6| 1 |2</span> | ||
+ | <span style='color:#696969; '>                  | |</span> | ||
+ | <span style='color:#696969; '>                   ---</span> | ||
+ | <span style='color:#696969; '>                  | 7 |</span> | ||
+ | <span style='color:#696969; '>                 5| |3</span> | ||
+ | <span style='color:#696969; '>                   ---</span> | ||
+ | <span style='color:#696969; '>               8° 4 bits: 12345678</span> | ||
+ | <span style='color:#696969; '>  Connectors:</span> | ||
+ | <span style='color:#696969; '>                CON3</span> | ||
+ | <span style='color:#696969; '>            GND GND GND </span> | ||
+ | <span style='color:#696969; '>        SW2 DATA</span> | ||
+ | <span style='color:#696969; '>   CON2 SW1 GND CON1 </span> | ||
+ | <span style='color:#696969; '>        CLK +5V</span> | ||
+ | <span style='color:#696969; '></span> | ||
+ | <span style='color:#696969; '> */</span> | ||
+ | <span style='color:#800000; font-weight:bold; '>unsigned</span> <span style='color:#800000; font-weight:bold; '>int</span> cnt <span style='color:#808030; '>=</span> <span style='color:#008c00; '>0</span><span style='color:#800080; '>;</span> | ||
+ | byte symbol<span style='color:#808030; '>,</span> symbols<span style='color:#808030; '>[</span><span style='color:#808030; '>]</span> <span style='color:#808030; '>=</span> <span style='color:#800080; '>{</span> | ||
+ | B11111100<span style='color:#808030; '>,</span> <span style='color:#696969; '>// 0</span> | ||
+ | B01100000<span style='color:#808030; '>,</span> <span style='color:#696969; '>// 1</span> | ||
+ | B11011010<span style='color:#808030; '>,</span> <span style='color:#696969; '>// 2</span> | ||
+ | B11110010<span style='color:#808030; '>,</span> <span style='color:#696969; '>// 3</span> | ||
+ | B01100110<span style='color:#808030; '>,</span> <span style='color:#696969; '>// 4</span> | ||
+ | B10110110<span style='color:#808030; '>,</span> <span style='color:#696969; '>// 5</span> | ||
+ | B10111110<span style='color:#808030; '>,</span> <span style='color:#696969; '>// 6</span> | ||
+ | B11100000<span style='color:#808030; '>,</span> <span style='color:#696969; '>// 7</span> | ||
+ | B11111110<span style='color:#808030; '>,</span> <span style='color:#696969; '>// 8</span> | ||
+ | B11110110<span style='color:#808030; '>,</span> <span style='color:#696969; '>// 9</span> | ||
+ | B11101110<span style='color:#808030; '>,</span> <span style='color:#696969; '>// A</span> | ||
+ | B00111110<span style='color:#808030; '>,</span> <span style='color:#696969; '>// B</span> | ||
+ | B10011100<span style='color:#808030; '>,</span> <span style='color:#696969; '>// C</span> | ||
+ | B01111010<span style='color:#808030; '>,</span> <span style='color:#696969; '>// D</span> | ||
+ | B10011110<span style='color:#808030; '>,</span> <span style='color:#696969; '>// E</span> | ||
+ | B10001110<span style='color:#808030; '>,</span> <span style='color:#696969; '>// F</span> | ||
+ | B00011100<span style='color:#808030; '>,</span> <span style='color:#696969; '>// L</span> | ||
+ | B00101010<span style='color:#808030; '>,</span> <span style='color:#696969; '>// M</span> | ||
+ | B11000110<span style='color:#808030; '>,</span> <span style='color:#696969; '>// °</span> | ||
+ | B01001010 <span style='color:#696969; '>// %</span> | ||
+ | <span style='color:#800080; '>}</span><span style='color:#800080; '>;</span> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | delay(1000); | + | |
+ | |||
+ | |||
+ | <span style='color:#800000; font-weight:bold; '>void</span> setup<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> | ||
+ | <span style='color:#800080; '>{</span> | ||
+ | pinMode<span style='color:#808030; '>(</span><span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> OUTPUT<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// make the clock pin an output</span> | ||
+ | pinMode<span style='color:#808030; '>(</span>data <span style='color:#808030; '>,</span> OUTPUT<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// make the data pin an output</span> | ||
+ | <span style='color:#800080; '>}</span> | ||
+ | |||
+ | <span style='color:#800000; font-weight:bold; '>void</span> loop<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span> | ||
+ | <span style='color:#696969; '>// put your main code here, to run repeatedly:</span> | ||
+ | |||
+ | |||
+ | shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B00000000<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send this binary value to the shift register</span> | ||
+ | shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B00000000<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send this binary value to the shift register</span> | ||
+ | shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B00000000<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send this binary value to the shift register</span> | ||
+ | shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B00000000<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send this binary value to the shift register</span> | ||
+ | delay<span style='color:#808030; '>(</span><span style='color:#008c00; '>1000</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> | ||
+ | shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B00000001<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send this binary value to the shift register</span> | ||
+ | shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B00000010<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send this binary value to the shift register</span> | ||
+ | shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B00000100<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send this binary value to the shift register</span> | ||
+ | shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B00001000<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send this binary value to the shift register</span> | ||
+ | delay<span style='color:#808030; '>(</span><span style='color:#008c00; '>1000</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> | ||
+ | shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B00010000<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send this binary value to the shift register</span> | ||
+ | shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B00100000<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send this binary value to the shift register</span> | ||
+ | shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B01000000<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send this binary value to the shift register</span> | ||
+ | shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B10000000<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send this binary value to the shift register</span> | ||
+ | delay<span style='color:#808030; '>(</span><span style='color:#008c00; '>1000</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> | ||
+ | shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B00000000<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send this binary value to the shift register</span> | ||
+ | shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B00000000<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send this binary value to the shift register</span> | ||
+ | shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B00000000<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send this binary value to the shift register</span> | ||
+ | shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B00000000<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send this binary value to the shift register</span> | ||
+ | |||
+ | delay<span style='color:#808030; '>(</span><span style='color:#008c00; '>1000</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> | ||
+ | |||
+ | shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B10101010<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send this binary value to the shift register</span> | ||
+ | delay<span style='color:#808030; '>(</span><span style='color:#008c00; '>1000</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> | ||
+ | |||
+ | <span style='color:#800000; font-weight:bold; '>for</span><span style='color:#808030; '>(</span><span style='color:#800000; font-weight:bold; '>int</span> i <span style='color:#808030; '>=</span> <span style='color:#008c00; '>0</span><span style='color:#800080; '>;</span> i <span style='color:#808030; '><</span> <span style='color:#008c00; '>4</span><span style='color:#800080; '>;</span> <span style='color:#808030; '>+</span><span style='color:#808030; '>+</span>i<span style='color:#808030; '>)</span> <span style='color:#696969; '>//for 0 - 7 do</span> | ||
+ | <span style='color:#800080; '>{</span> | ||
+ | shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B01010101<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// bit shift a logic high (1) value by i</span> | ||
+ | delay<span style='color:#808030; '>(</span><span style='color:#008c00; '>500</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// delay 100ms or you would not be able to see it</span> | ||
+ | <span style='color:#800080; '>}</span> | ||
+ | delay<span style='color:#808030; '>(</span><span style='color:#008c00; '>1000</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> | ||
+ | |||
+ | <span style='color:#800000; font-weight:bold; '>for</span><span style='color:#808030; '>(</span><span style='color:#800000; font-weight:bold; '>int</span> i <span style='color:#808030; '>=</span> <span style='color:#008c00; '>0</span><span style='color:#800080; '>;</span> i <span style='color:#808030; '><</span> <span style='color:#008c00; '>4</span><span style='color:#800080; '>;</span> <span style='color:#808030; '>+</span><span style='color:#808030; '>+</span>i<span style='color:#808030; '>)</span> <span style='color:#696969; '>//for 0 - 7 do</span> | ||
+ | <span style='color:#800080; '>{</span> | ||
+ | shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B10101010<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// bit shift a logic high (1) value by i</span> | ||
+ | delay<span style='color:#808030; '>(</span><span style='color:#008c00; '>500</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// delay 100ms or you would not be able to see it</span> | ||
+ | <span style='color:#800080; '>}</span> | ||
+ | |||
+ | delay<span style='color:#808030; '>(</span><span style='color:#008c00; '>1500</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> | ||
+ | |||
+ | <span style='color:#800000; font-weight:bold; '>for</span><span style='color:#808030; '>(</span><span style='color:#800000; font-weight:bold; '>int</span> i <span style='color:#808030; '>=</span> <span style='color:#008c00; '>0</span><span style='color:#800080; '>;</span> i <span style='color:#808030; '><</span> <span style='color:#008c00; '>12</span><span style='color:#800080; '>;</span> <span style='color:#808030; '>+</span><span style='color:#808030; '>+</span>i<span style='color:#808030; '>)</span> <span style='color:#696969; '>//for 0 - 7 do</span> | ||
+ | <span style='color:#800080; '>{</span> | ||
+ | shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> MSBFIRST<span style='color:#808030; '>,</span> <span style='color:#008c00; '>1</span> <span style='color:#808030; '><</span><span style='color:#808030; '><</span> i <span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// bit shift a logic high (1) value by i</span> | ||
+ | delay<span style='color:#808030; '>(</span><span style='color:#008c00; '>300</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// delay 100ms or you would not be able to see it</span> | ||
+ | <span style='color:#800080; '>}</span> | ||
+ | |||
+ | delay<span style='color:#808030; '>(</span><span style='color:#008c00; '>1000</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> | ||
+ | |||
+ | |||
+ | <span style='color:#800000; font-weight:bold; '>for</span><span style='color:#808030; '>(</span><span style='color:#800000; font-weight:bold; '>int</span> i <span style='color:#808030; '>=</span> <span style='color:#008c00; '>0</span><span style='color:#800080; '>;</span> i <span style='color:#808030; '><</span> <span style='color:#008c00; '>19</span><span style='color:#800080; '>;</span> <span style='color:#808030; '>+</span><span style='color:#808030; '>+</span>i<span style='color:#808030; '>)</span> <span style='color:#696969; '>// counter 0 to F puis -> %</span> | ||
+ | <span style='color:#800080; '>{</span> | ||
+ | cnt<span style='color:#808030; '>=</span>i<span style='color:#800080; '>;</span> | ||
+ | symbol <span style='color:#808030; '>=</span> symbols<span style='color:#808030; '>[</span>cnt<span style='color:#808030; '>+</span><span style='color:#808030; '>+</span><span style='color:#808030; '>%</span><span style='color:#800000; font-weight:bold; '>sizeof</span><span style='color:#808030; '>(</span>symbols<span style='color:#808030; '>)</span><span style='color:#808030; '>]</span> <span style='color:#808030; '>|</span> <span style='color:#808030; '>(</span>cnt<span style='color:#808030; '>%</span><span style='color:#008c00; '>2</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> | ||
+ | shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> symbol<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send data</span> | ||
+ | delay<span style='color:#808030; '>(</span><span style='color:#008c00; '>500</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// pause for 1/2 second</span> | ||
+ | <span style='color:#800080; '>}</span> | ||
+ | |||
+ | cnt <span style='color:#808030; '>=</span> <span style='color:#008c00; '>17</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>//M</span> | ||
+ | symbol <span style='color:#808030; '>=</span> symbols<span style='color:#808030; '>[</span>cnt<span style='color:#808030; '>+</span><span style='color:#808030; '>+</span><span style='color:#808030; '>%</span><span style='color:#800000; font-weight:bold; '>sizeof</span><span style='color:#808030; '>(</span>symbols<span style='color:#808030; '>)</span><span style='color:#808030; '>]</span> <span style='color:#808030; '>|</span> <span style='color:#808030; '>(</span>cnt<span style='color:#808030; '>%</span><span style='color:#008c00; '>2</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> | ||
+ | shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> symbol<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send data</span> | ||
+ | cnt <span style='color:#808030; '>=</span> <span style='color:#008c00; '>14</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>//E</span> | ||
+ | symbol <span style='color:#808030; '>=</span> symbols<span style='color:#808030; '>[</span>cnt<span style='color:#808030; '>+</span><span style='color:#808030; '>+</span><span style='color:#808030; '>%</span><span style='color:#800000; font-weight:bold; '>sizeof</span><span style='color:#808030; '>(</span>symbols<span style='color:#808030; '>)</span><span style='color:#808030; '>]</span> <span style='color:#808030; '>|</span> <span style='color:#808030; '>(</span>cnt<span style='color:#808030; '>%</span><span style='color:#008c00; '>2</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> | ||
+ | shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> symbol<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send data</span> | ||
+ | cnt <span style='color:#808030; '>=</span> <span style='color:#008c00; '>16</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>//L</span> | ||
+ | symbol <span style='color:#808030; '>=</span> symbols<span style='color:#808030; '>[</span>cnt<span style='color:#808030; '>+</span><span style='color:#808030; '>+</span><span style='color:#808030; '>%</span><span style='color:#800000; font-weight:bold; '>sizeof</span><span style='color:#808030; '>(</span>symbols<span style='color:#808030; '>)</span><span style='color:#808030; '>]</span> <span style='color:#808030; '>|</span> <span style='color:#808030; '>(</span>cnt<span style='color:#808030; '>%</span><span style='color:#008c00; '>2</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> | ||
+ | shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> symbol<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send data</span> | ||
+ | cnt <span style='color:#808030; '>=</span> <span style='color:#008c00; '>12</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>//C</span> | ||
+ | symbol <span style='color:#808030; '>=</span> symbols<span style='color:#808030; '>[</span>cnt<span style='color:#808030; '>+</span><span style='color:#808030; '>+</span><span style='color:#808030; '>%</span><span style='color:#800000; font-weight:bold; '>sizeof</span><span style='color:#808030; '>(</span>symbols<span style='color:#808030; '>)</span><span style='color:#808030; '>]</span> <span style='color:#808030; '>|</span> <span style='color:#808030; '>(</span>cnt<span style='color:#808030; '>%</span><span style='color:#008c00; '>2</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> | ||
+ | shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> symbol<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send data</span> | ||
+ | delay<span style='color:#808030; '>(</span><span style='color:#008c00; '>4000</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> | ||
+ | |||
+ | <span style='color:#800080; '>}</span> | ||
+ | </pre> | ||
+ | ]] | ||
}} | }} | ||
{{Notes}} | {{Notes}} | ||
{{Tuto Status}} | {{Tuto Status}} |
Version du 29 janvier 2019 à 21:40
Une Technique de dans les catégories Électronique. Dernière modification le 22/04/2022 par Sgiraud.
Réutiliser un afficheur LED digital pour des projets Arduino. Exemple avec 4 registres à décalage HC164
Sommaire
Introduction
Il est courant de trouver dans les bacs de récupération des afficheurs 7 segments LED avec registre à décalage. La connexion à ses afficheurs est simple, elle n'a besoin que de 2 fils: clock et data. L'Arduino est parfaitement adapté pour générer les bons signaux.
Liste des matériaux
- 1 Display à LED 7 segment et Registre à décalage
- Des fils avec connecteurs
Liste des outils
- 1 fer à souder
- De quoi dessouder ou couper une connexion
- 1 Arduino Nano
- 1 Testeur (Voltmètre/Ohmmètre)
- En option 1 shield Nano
Etape n°1 - Récupérer le display
Par exemple, ici, le display provient d'une carte de climatiseur. Il y a 4 x 8 segments, avec 3 x 3 connecteurs bien visibles. Le 8ieme segment correspond au point après chaque chiffre. On ne voit pas les registres, mais il y en a très probablement puisqu'il n'y a que 7 connecteurs (hors masse et alimentation) pour 32 segments.
Reste à dessouder les 9 connecteurs, ou (plus rapide) les couper à la pince.
Etape n°2 - Trouver les registres à décalages
Il y a bien 4 chips derrière, qui correspondent à chacun des chiffres de l'afficheur. Après nettoyage et avec une bonne loupe, on arrive à lire "HC164". C'est une registre à décalage très courant et simple.
La doc est facile à trouver (voir ci-joint) et le principe simple:
- A chaque transition sur le pin CLK (Clock)
- La valeur en entrée DATA est "poussée" dans le registre et décale les 8 bits qui y étaient déjà.
- Le 8ieme bit est chainé sur l'entrée DATA du registre suivant
- Ainsi, après 8 x 4 = 32 transitions, tous les bits des 4 display sont valorisés.
Etape n°3 - Recherche de la masse
La carte est multi-couches, donc assez compliqué de s'y retrouver dans le circuit. En testant la connectivité entre les connecteurs, 4 connecteurs s'avèrent en lien direct (résistance nulle): les 3 du haut (CON3) et celui au centre à droite (CON1). Ceux-ci sont visiblement connectés sur le circuit à de grandes surfaces conductrices qui est très probablement la masse.
Etape n°4 - Recherche de l'alimentation +5V
Plus simple qu'il n'y parait: en général sur le circuit, le VCC est visualisé par une gravure "carrée". Justement, il y a un lien entre un carré sur le circuit et le connecteur le plus bas du CON1.
On peut alimenter ! Les LED vont s'afficher un peu au hasard au gré des mauvais contacts et parasites.
Victoire!
Etape n°5 - Recherche du Clk et Data
Plusieurs méthodes:
- Suivre les circuits CLK et DATA qui partent des HC164: L'idéal serait de pouvoir suivre les circuits visuellement, mais sur cette carte multi-couches c'est très difficile.
- Utiliser l'ohmètre pour trouver les liens avec les connecteurs: Pas de chance, aucun lien direct.
- Par élimination: On peut ignorer les 2 connecteurs du haut de CON 2: ceux-ci sont reliés aux interrupteurs sous le display.
Ainsi, il ne reste que 2 candidats: en haut du CON1 et en bas du CON2.
Avec un fil, connecter au + l'un des 2 pins. Le Data n'affiche rien. Mais le Clock fait avancer les segments de gauche à droite.
On a maintenant les 2 pins: voir la photo.
Etape n°6 - Connexion à l'Arduino
On peut connecter à l'Arduino, par exemple:
- GND -> GND
- CON+ -> VCC
- CLK -> Pin D3 (PWM)
- DATA -> Pin 2
Voici un exemple de code qui permet de contrôler totalement l'affichage.
Et voilà! Plus besoin de commander un nouvel afficheur au bout du monde...
Etape n°7 - Le Code
<span style='color:#004a43; '>#</span><span style='color:#004a43; '>define</span><span style='color:#004a43; '> data 2</span> <span style='color:#004a43; '>#</span><span style='color:#004a43; '>define</span><span style='color:#004a43; '> clock 3 </span><span style='color:#696969; '>//D PWM</span> <span style='color:#696969; '>/*</span> <span style='color:#696969; '> * CHILLER DISP Rev 0.0</span> <span style='color:#696969; '> LED Display: ___</span> <span style='color:#696969; '> 6| 1 |2</span> <span style='color:#696969; '> | |</span> <span style='color:#696969; '> ---</span> <span style='color:#696969; '> | 7 |</span> <span style='color:#696969; '> 5| |3</span> <span style='color:#696969; '> ---</span> <span style='color:#696969; '> 8° 4 bits: 12345678</span> <span style='color:#696969; '> Connectors:</span> <span style='color:#696969; '> CON3</span> <span style='color:#696969; '> GND GND GND </span> <span style='color:#696969; '> SW2 DATA</span> <span style='color:#696969; '> CON2 SW1 GND CON1 </span> <span style='color:#696969; '> CLK +5V</span> <span style='color:#696969; '></span> <span style='color:#696969; '> */</span> <span style='color:#800000; font-weight:bold; '>unsigned</span> <span style='color:#800000; font-weight:bold; '>int</span> cnt <span style='color:#808030; '>=</span> <span style='color:#008c00; '>0</span><span style='color:#800080; '>;</span> byte symbol<span style='color:#808030; '>,</span> symbols<span style='color:#808030; '>[</span><span style='color:#808030; '>]</span> <span style='color:#808030; '>=</span> <span style='color:#800080; '>{</span> B11111100<span style='color:#808030; '>,</span> <span style='color:#696969; '>// 0</span> B01100000<span style='color:#808030; '>,</span> <span style='color:#696969; '>// 1</span> B11011010<span style='color:#808030; '>,</span> <span style='color:#696969; '>// 2</span> B11110010<span style='color:#808030; '>,</span> <span style='color:#696969; '>// 3</span> B01100110<span style='color:#808030; '>,</span> <span style='color:#696969; '>// 4</span> B10110110<span style='color:#808030; '>,</span> <span style='color:#696969; '>// 5</span> B10111110<span style='color:#808030; '>,</span> <span style='color:#696969; '>// 6</span> B11100000<span style='color:#808030; '>,</span> <span style='color:#696969; '>// 7</span> B11111110<span style='color:#808030; '>,</span> <span style='color:#696969; '>// 8</span> B11110110<span style='color:#808030; '>,</span> <span style='color:#696969; '>// 9</span> B11101110<span style='color:#808030; '>,</span> <span style='color:#696969; '>// A</span> B00111110<span style='color:#808030; '>,</span> <span style='color:#696969; '>// B</span> B10011100<span style='color:#808030; '>,</span> <span style='color:#696969; '>// C</span> B01111010<span style='color:#808030; '>,</span> <span style='color:#696969; '>// D</span> B10011110<span style='color:#808030; '>,</span> <span style='color:#696969; '>// E</span> B10001110<span style='color:#808030; '>,</span> <span style='color:#696969; '>// F</span> B00011100<span style='color:#808030; '>,</span> <span style='color:#696969; '>// L</span> B00101010<span style='color:#808030; '>,</span> <span style='color:#696969; '>// M</span> B11000110<span style='color:#808030; '>,</span> <span style='color:#696969; '>// °</span> B01001010 <span style='color:#696969; '>// %</span> <span style='color:#800080; '>}</span><span style='color:#800080; '>;</span> <span style='color:#800000; font-weight:bold; '>void</span> setup<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span> pinMode<span style='color:#808030; '>(</span><span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> OUTPUT<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// make the clock pin an output</span> pinMode<span style='color:#808030; '>(</span>data <span style='color:#808030; '>,</span> OUTPUT<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// make the data pin an output</span> <span style='color:#800080; '>}</span> <span style='color:#800000; font-weight:bold; '>void</span> loop<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span> <span style='color:#800080; '>{</span> <span style='color:#696969; '>// put your main code here, to run repeatedly:</span> shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B00000000<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send this binary value to the shift register</span> shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B00000000<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send this binary value to the shift register</span> shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B00000000<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send this binary value to the shift register</span> shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B00000000<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send this binary value to the shift register</span> delay<span style='color:#808030; '>(</span><span style='color:#008c00; '>1000</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B00000001<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send this binary value to the shift register</span> shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B00000010<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send this binary value to the shift register</span> shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B00000100<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send this binary value to the shift register</span> shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B00001000<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send this binary value to the shift register</span> delay<span style='color:#808030; '>(</span><span style='color:#008c00; '>1000</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B00010000<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send this binary value to the shift register</span> shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B00100000<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send this binary value to the shift register</span> shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B01000000<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send this binary value to the shift register</span> shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B10000000<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send this binary value to the shift register</span> delay<span style='color:#808030; '>(</span><span style='color:#008c00; '>1000</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B00000000<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send this binary value to the shift register</span> shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B00000000<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send this binary value to the shift register</span> shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B00000000<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send this binary value to the shift register</span> shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B00000000<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send this binary value to the shift register</span> delay<span style='color:#808030; '>(</span><span style='color:#008c00; '>1000</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B10101010<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send this binary value to the shift register</span> delay<span style='color:#808030; '>(</span><span style='color:#008c00; '>1000</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#800000; font-weight:bold; '>for</span><span style='color:#808030; '>(</span><span style='color:#800000; font-weight:bold; '>int</span> i <span style='color:#808030; '>=</span> <span style='color:#008c00; '>0</span><span style='color:#800080; '>;</span> i <span style='color:#808030; '><</span> <span style='color:#008c00; '>4</span><span style='color:#800080; '>;</span> <span style='color:#808030; '>+</span><span style='color:#808030; '>+</span>i<span style='color:#808030; '>)</span> <span style='color:#696969; '>//for 0 - 7 do</span> <span style='color:#800080; '>{</span> shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B01010101<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// bit shift a logic high (1) value by i</span> delay<span style='color:#808030; '>(</span><span style='color:#008c00; '>500</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// delay 100ms or you would not be able to see it</span> <span style='color:#800080; '>}</span> delay<span style='color:#808030; '>(</span><span style='color:#008c00; '>1000</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#800000; font-weight:bold; '>for</span><span style='color:#808030; '>(</span><span style='color:#800000; font-weight:bold; '>int</span> i <span style='color:#808030; '>=</span> <span style='color:#008c00; '>0</span><span style='color:#800080; '>;</span> i <span style='color:#808030; '><</span> <span style='color:#008c00; '>4</span><span style='color:#800080; '>;</span> <span style='color:#808030; '>+</span><span style='color:#808030; '>+</span>i<span style='color:#808030; '>)</span> <span style='color:#696969; '>//for 0 - 7 do</span> <span style='color:#800080; '>{</span> shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> B10101010<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// bit shift a logic high (1) value by i</span> delay<span style='color:#808030; '>(</span><span style='color:#008c00; '>500</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// delay 100ms or you would not be able to see it</span> <span style='color:#800080; '>}</span> delay<span style='color:#808030; '>(</span><span style='color:#008c00; '>1500</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#800000; font-weight:bold; '>for</span><span style='color:#808030; '>(</span><span style='color:#800000; font-weight:bold; '>int</span> i <span style='color:#808030; '>=</span> <span style='color:#008c00; '>0</span><span style='color:#800080; '>;</span> i <span style='color:#808030; '><</span> <span style='color:#008c00; '>12</span><span style='color:#800080; '>;</span> <span style='color:#808030; '>+</span><span style='color:#808030; '>+</span>i<span style='color:#808030; '>)</span> <span style='color:#696969; '>//for 0 - 7 do</span> <span style='color:#800080; '>{</span> shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> MSBFIRST<span style='color:#808030; '>,</span> <span style='color:#008c00; '>1</span> <span style='color:#808030; '><</span><span style='color:#808030; '><</span> i <span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// bit shift a logic high (1) value by i</span> delay<span style='color:#808030; '>(</span><span style='color:#008c00; '>300</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// delay 100ms or you would not be able to see it</span> <span style='color:#800080; '>}</span> delay<span style='color:#808030; '>(</span><span style='color:#008c00; '>1000</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#800000; font-weight:bold; '>for</span><span style='color:#808030; '>(</span><span style='color:#800000; font-weight:bold; '>int</span> i <span style='color:#808030; '>=</span> <span style='color:#008c00; '>0</span><span style='color:#800080; '>;</span> i <span style='color:#808030; '><</span> <span style='color:#008c00; '>19</span><span style='color:#800080; '>;</span> <span style='color:#808030; '>+</span><span style='color:#808030; '>+</span>i<span style='color:#808030; '>)</span> <span style='color:#696969; '>// counter 0 to F puis -> %</span> <span style='color:#800080; '>{</span> cnt<span style='color:#808030; '>=</span>i<span style='color:#800080; '>;</span> symbol <span style='color:#808030; '>=</span> symbols<span style='color:#808030; '>[</span>cnt<span style='color:#808030; '>+</span><span style='color:#808030; '>+</span><span style='color:#808030; '>%</span><span style='color:#800000; font-weight:bold; '>sizeof</span><span style='color:#808030; '>(</span>symbols<span style='color:#808030; '>)</span><span style='color:#808030; '>]</span> <span style='color:#808030; '>|</span> <span style='color:#808030; '>(</span>cnt<span style='color:#808030; '>%</span><span style='color:#008c00; '>2</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> symbol<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send data</span> delay<span style='color:#808030; '>(</span><span style='color:#008c00; '>500</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// pause for 1/2 second</span> <span style='color:#800080; '>}</span> cnt <span style='color:#808030; '>=</span> <span style='color:#008c00; '>17</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>//M</span> symbol <span style='color:#808030; '>=</span> symbols<span style='color:#808030; '>[</span>cnt<span style='color:#808030; '>+</span><span style='color:#808030; '>+</span><span style='color:#808030; '>%</span><span style='color:#800000; font-weight:bold; '>sizeof</span><span style='color:#808030; '>(</span>symbols<span style='color:#808030; '>)</span><span style='color:#808030; '>]</span> <span style='color:#808030; '>|</span> <span style='color:#808030; '>(</span>cnt<span style='color:#808030; '>%</span><span style='color:#008c00; '>2</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> symbol<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send data</span> cnt <span style='color:#808030; '>=</span> <span style='color:#008c00; '>14</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>//E</span> symbol <span style='color:#808030; '>=</span> symbols<span style='color:#808030; '>[</span>cnt<span style='color:#808030; '>+</span><span style='color:#808030; '>+</span><span style='color:#808030; '>%</span><span style='color:#800000; font-weight:bold; '>sizeof</span><span style='color:#808030; '>(</span>symbols<span style='color:#808030; '>)</span><span style='color:#808030; '>]</span> <span style='color:#808030; '>|</span> <span style='color:#808030; '>(</span>cnt<span style='color:#808030; '>%</span><span style='color:#008c00; '>2</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> symbol<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send data</span> cnt <span style='color:#808030; '>=</span> <span style='color:#008c00; '>16</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>//L</span> symbol <span style='color:#808030; '>=</span> symbols<span style='color:#808030; '>[</span>cnt<span style='color:#808030; '>+</span><span style='color:#808030; '>+</span><span style='color:#808030; '>%</span><span style='color:#800000; font-weight:bold; '>sizeof</span><span style='color:#808030; '>(</span>symbols<span style='color:#808030; '>)</span><span style='color:#808030; '>]</span> <span style='color:#808030; '>|</span> <span style='color:#808030; '>(</span>cnt<span style='color:#808030; '>%</span><span style='color:#008c00; '>2</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> symbol<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send data</span> cnt <span style='color:#808030; '>=</span> <span style='color:#008c00; '>12</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>//C</span> symbol <span style='color:#808030; '>=</span> symbols<span style='color:#808030; '>[</span>cnt<span style='color:#808030; '>+</span><span style='color:#808030; '>+</span><span style='color:#808030; '>%</span><span style='color:#800000; font-weight:bold; '>sizeof</span><span style='color:#808030; '>(</span>symbols<span style='color:#808030; '>)</span><span style='color:#808030; '>]</span> <span style='color:#808030; '>|</span> <span style='color:#808030; '>(</span>cnt<span style='color:#808030; '>%</span><span style='color:#008c00; '>2</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> shiftOut<span style='color:#808030; '>(</span>data<span style='color:#808030; '>,</span> <span style='color:#603000; '>clock</span><span style='color:#808030; '>,</span> LSBFIRST<span style='color:#808030; '>,</span> symbol<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#696969; '>// send data</span> delay<span style='color:#808030; '>(</span><span style='color:#008c00; '>4000</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span> <span style='color:#800080; '>}</span>]] » contient des marqueurs de bande et ne peut donc pas être suffisamment analysée.