Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int DELAY = 100;
- char data_;
- int delays[] = {100, 200, 300, 50};
- int flag = 0;
- int i = 0x01;
- int j = 0;
- void blinc() {
- for (i = 0x01; i < 0x09; i = i << 1) {
- LATA = i;
- if (i == 0x01) {
- Sound_Play(1337, 10);
- } else {
- Sound_Play(684, 10);
- }
- Delay_ms(10);
- LATA = 0x00;
- for (j = 0; j < DELAY; j++) {
- Delay_ms(1);
- }
- }
- }
- void main() {
- ANSELC = 0;
- TRISA = 0;
- Sound_Init(&PORTE, 1);
- UART1_Init(9600);
- Delay_ms(100);
- while(1) {
- if (UART1_Data_Ready()) {
- data_ = UART1_Read();
- flag += 1;
- if (flag > 3) flag = 0;
- DELAY = delays[flag];
- Sound_Play(2048, 100);
- Delay_ms(100);
- }
- blinc();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment