Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- unsigned long contador = 0;
- #define bit4 4
- #define bit5 5
- #define bit6 6
- #define bit7 7
- #define Com1 8
- #define Com2 9
- #define Com3 10
- #define Com4 11
- #define Com5 12
- #define Com6 13
- byte dig[7];
- int j = 0;
- //------------------------------
- void setup()
- {
- Serial.begin(9600);
- pinMode (bit4, OUTPUT);
- pinMode (bit5, OUTPUT);
- pinMode (bit6, OUTPUT);
- pinMode (bit7, OUTPUT);
- pinMode (Com1, OUTPUT);
- pinMode (Com2, OUTPUT);
- pinMode (Com3, OUTPUT);
- pinMode (Com4, OUTPUT);
- pinMode (Com5, OUTPUT);
- pinMode (Com6, OUTPUT);
- }
- //------------------------------
- void loop()
- {
- contador++;
- for (int i = 0; i < 6; i++)
- {
- if ((contador >> (i * 4) & 0x0000000F) == 0x0000000A) contador = contador + 6 * ( pow(10, i));
- }
- Serial.print("contador "); Serial.println(contador, HEX);
- for (int i = 0; i < 6; i++)
- {
- dig[i] = contador >> (i * 4) & 0x0000000F;
- Serial.print(" digito "); Serial.println(dig[i]);
- }
- digitalWrite(Com1, HIGH);
- Display7Seg();
- j++;
- digitalWrite(Com1, LOW);
- digitalWrite(Com2, HIGH);
- Display7Seg();
- j++;
- digitalWrite(Com2, LOW);
- digitalWrite(Com3, HIGH);
- Display7Seg();
- j++;
- digitalWrite(Com3, LOW);
- digitalWrite(Com4, HIGH);
- Display7Seg();
- j++;
- digitalWrite(Com4, LOW);
- digitalWrite(Com5, HIGH);
- Display7Seg();
- j++;
- digitalWrite(Com5, LOW);
- digitalWrite(Com6, HIGH);
- Display7Seg();
- j=0;
- digitalWrite(Com6, LOW);
- delay(200);
- }
- //-----------------------------
- void Display7Seg()
- {
- digitalWrite(bit4, (dig[j] & 0x08) );
- digitalWrite(bit5, (dig[j] & 0x04) );
- digitalWrite(bit6, (dig[j] & 0x02) );
- digitalWrite(bit7, (dig[j] & 0x01) );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement