uas_arduino

Shift Test

Jan 30th, 2015
193
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. byte data = 11;
  2. byte clk = 12;
  3. byte latch = 8;
  4.  
  5. void setup() {
  6.   pinMode(data, OUTPUT);
  7.   pinMode(clk, OUTPUT);
  8.   pinMode(latch, OUTPUT);
  9. }
  10.  
  11.  
  12. void loop() {
  13.   for(int a = 0; a < 65535; a++){
  14.     for(byte pos = 0; pos < 16; pos++){
  15.       if(a & (0x01 << pos)){
  16.         digitalWrite(data, HIGH);
  17.       }else{
  18.         digitalWrite(data, LOW);        
  19.       }
  20.      
  21.       digitalWrite(clk, LOW);
  22.       digitalWrite(clk, HIGH);
  23.       digitalWrite(latch, LOW);
  24.       digitalWrite(latch, HIGH);
  25.      
  26.       delay(100);
  27.     }
  28.     delay(1000);
  29.   }
  30. }
RAW Paste Data