Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * GccApplication1.cpp
- *
- * Created: 05.02.2014 21:11:27
- * Author: nike
- */
- #define F_CPU 1000000UL
- #include <avr/io.h>
- #include <util/delay.h> // Хотим использовать функции задержек
- void IndicatorOn(char number, char lightTime)
- {
- unsigned char numbers[] =
- {
- 0x3f, //0
- 0x06, //1
- 0x5b, //2
- 0x4f, //3
- 0x66, //4
- 0x6d, //5
- 0x7d, //6
- 0x07, //7
- 0x7f, //8
- 0x6f //9
- };
- int j, tens, nums;
- DDRA = 0xff; // portA exits
- for (j=0; j != lightTime; j++)
- {
- PORTB = 0x00;
- tens = number / 10;
- nums = number % 10;
- PORTB = numbers[tens];
- PORTA = 0b00000010;
- _delay_ms(20);
- PORTB = numbers[nums];
- PORTA = 0b00000001;
- _delay_ms(20);
- }
- }
- int main(void)
- {
- DDRB = 0xff;
- while(1)
- {
- int i;
- for (i=0; i !=50; i++ )
- {
- IndicatorOn (i, 10);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement