Advertisement
Guest User

Untitled

a guest
Jun 18th, 2018
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.47 KB | None | 0 0
  1. void getamountlights(int x) {
  2.   int result;
  3.   result = ((x - minrange) / ((range - minrange) / amountlights));
  4.   lights(result);
  5. }
  6. void lights(int x) {
  7.   int a;
  8.   x = constrain(x, 0, 40);
  9.   for (int i = 0; i < x; i++) {
  10.     bin[i] = 1;
  11.   }
  12.   a = 40 - x;
  13.   for (int i = 0; i < a; i++) {
  14.     bin[x + i] = 0;
  15.   }
  16. }
  17. int binget(int x) {
  18.   int result = 0;
  19.   for (int i = x; i < x + 8; i++) {
  20.     result = result + (bin[i] * (1 << i - x));
  21.   }
  22.   return result;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement