|
|
(10 révisions intermédiaires par le même utilisateur non affichées) |
Ligne 2 : |
Ligne 2 : |
| |Type=Technique | | |Type=Technique |
| |Area=Électronique | | |Area=Électronique |
− | |Tags=Registre à décalage, affichage, LED, 7 segments, display, Réutilisation, Récupération, HC164, | + | |Tags=Registre à décalage, affichage, LED, 7 segments, display, Réutilisation, Récupération, HC164, carte-arduino |
| |Description=Réutiliser un afficheur LED digital pour des projets Arduino. Exemple avec 4 registres à décalage HC164 | | |Description=Réutiliser un afficheur LED digital pour des projets Arduino. Exemple avec 4 registres à décalage HC164 |
| |Difficulty=Facile | | |Difficulty=Facile |
Ligne 110 : |
Ligne 110 : |
| {{Tuto Step | | {{Tuto Step |
| |Step_Title=Le Code | | |Step_Title=Le Code |
− | |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> | + | |Step_Content=<code> |
− | <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>
| + | ; #define data 2 |
| + | ; #define clock 3; //D PWM |
| + | ; |
| + | ;void setup() |
| + | ;{ |
| + | ;;;pinMode(clock, OUTPUT); // make the clock pin an output |
| + | ;;;pinMode(data , OUTPUT); // make the data pin an output |
| + | ; } |
| | | |
− | <span style='color:#696969; '>/*</span>
| + | ;void loop() { |
− | <span style='color:#696969; '> * CHILLER DISP Rev 0.0</span>
| + | ;;;// put your main code here, to run repeatedly: |
− | <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>
| |
| | | |
| + | ;;;shiftOut(data, clock, LSBFIRST, B00000000); // send this binary value to the shift register |
| + | ;;;shiftOut(data, clock, LSBFIRST, B00000000); // send this binary value to the shift register |
| + | ;;;shiftOut(data, clock, LSBFIRST, B00000000); // send this binary value to the shift register |
| + | ;;;shiftOut(data, clock, LSBFIRST, B00000000); // send this binary value to the shift register |
| + | ;;;delay(1000);;; |
| + | ;;;shiftOut(data, clock, LSBFIRST, B00000001); // send this binary value to the shift register |
| + | ;;;shiftOut(data, clock, LSBFIRST, B00000010); // send this binary value to the shift register |
| + | ;;;shiftOut(data, clock, LSBFIRST, B00000100); // send this binary value to the shift register |
| + | ;;;shiftOut(data, clock, LSBFIRST, B00001000); // send this binary value to the shift register |
| + | ;;;delay(1000);;; |
| + | ;;;shiftOut(data, clock, LSBFIRST, B00010000); // send this binary value to the shift register |
| + | ;;;shiftOut(data, clock, LSBFIRST, B00100000); // send this binary value to the shift register |
| + | ;;;shiftOut(data, clock, LSBFIRST, B01000000); // send this binary value to the shift register |
| + | ;;;shiftOut(data, clock, LSBFIRST, B10000000); // send this binary value to the shift register |
| + | ;;;delay(1000);;; |
| + | ;;;shiftOut(data, clock, LSBFIRST, B00000000); // send this binary value to the shift register |
| + | ;;;shiftOut(data, clock, LSBFIRST, B00000000); // send this binary value to the shift register |
| + | ;;;shiftOut(data, clock, LSBFIRST, B00000000); // send this binary value to the shift register |
| + | ;;;shiftOut(data, clock, LSBFIRST, B00000000); // send this binary value to the shift register |
| | | |
| + | ;;;delay(1000);;; |
| | | |
| + | ;;;shiftOut(data, clock, LSBFIRST, B10101010); // send this binary value to the shift register |
| + | ;;;delay(1000); |
| | | |
| + | ; for(int i = 0; i < 4; ++i) //for 0 - 7 do |
| + | ;;;{ |
| + | ;;;;;shiftOut(data, clock, LSBFIRST, B01010101); // bit shift a logic high (1) value by i |
| + | ;;;;;delay(500); // delay 100ms or you would not be able to see it |
| + | ;;;} |
| + | ;;;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>
| + | </code> |
− | 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}} |