daily pastebin goal
5%
SHARE
TWEET

CONVERTE_PARA_BIN

a guest Sep 13th, 2017 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <math.h>
  2. #define ARC 8
  3.  
  4. int pin = 13;
  5. int pin_finish = 12;
  6.  
  7. int bits[8] = {0,0,0,0,0,0,0,0};
  8. void setup() {
  9.   pinMode(pin, OUTPUT);
  10.   bit_to_arr( num_to_bit(10), bits );
  11. }
  12. void bit_to_arr(int x, int * bits_of_num){
  13.     int t;
  14.     int rem;
  15.     for(t=0;x>0;t++){
  16.         rem=x%10;
  17.         bits_of_num[t] = rem;
  18.         x/=10;
  19.     }
  20. }
  21. int num_to_bit(int x){
  22.     int t=0;
  23.     int final_num=0;
  24.     for(;x!=0;t++){
  25.         final_num+=(x%2)*(pow(10,t));
  26.         x /= 2;
  27.     }
  28.     return final_num;
  29. }
  30. int i;
  31. void loop() {
  32.   i=0;
  33.   for(;i<ARC;i++)
  34.     digitalWrite(pin, bits[i]);
  35.  
  36.   delay(1000);
  37.   digitalWrite(pin_finish, HIGH);
  38.   delay(500);
  39.   digitalWrite(pin_finish, LOW);
  40.   delay(1000);
  41.   //digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
  42.   //delay(1000);               // wait for a second
  43.   //digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
  44.   //delay(1000);               // wait for a second
  45. }
RAW Paste Data
Top