Advertisement
michelangelodr

12 bit binary counter

May 27th, 2018
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.47 KB | None | 0 0
  1. // by M. De Riso
  2. // 2^12 binary counter
  3.  
  4. void setup()
  5. {
  6.   Serial.begin(9600);
  7. }
  8.  
  9. void loop()
  10. {
  11.   digitalWrite(13, HIGH);
  12.   delay(100); // Wait for x millisecond(s)
  13.   digitalWrite(13, LOW);
  14.   delay(100); // Wait for x millisecond(s)
  15.  
  16.   int bit;
  17.   for(int num=0;num<=4095;num++)
  18.   {
  19.     String nums="";
  20.     int n=num;
  21.     for(int i=11;i>=0;i--) {
  22.         bit=n % 2;
  23.         n=n/2;
  24.         nums = (String) bit + nums;
  25.     }
  26.   Serial.println(nums + "  ");
  27.   }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement