Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //EXPERIMENT # 2 - EXERCISE 1
- //BALMORI, KEVIN M. / GROUP # 4
- //JANUARY 27, 2014
- //DIFFERENT LED SEQUENCE USING SENSORS
- #include<ez8.h>
- #define sw1 (PBIN&0x01)
- #define sw2 (PBIN&0x02)
- #define sw3 (PBIN&0x04)
- #define sw4 (PBIN&0x08)
- void delay_ms(unsigned int delay);
- void main()
- {
- PADD = 0X00;// Data Direction=Output;
- PAAF = 0X00;// Alternate Function=Normal;
- PAOC = 0X00;// Output Control=Push/pull;
- PAHDE = 0XFF;// High Drive Enable=15mA;
- PBDD |= 0X0F;// Data Direction=Input;
- PBAF &=~0X0F;// Alternate Function=Normal;
- while(1)
- {
- if ((sw1==0)&&(sw2!=0)&&(sw3!=0)&&(sw4!=0))
- {
- PAOUT =~0xC0;delay_ms(500);
- PAOUT =~0x60;delay_ms(500);
- PAOUT =~0x30;delay_ms(500);
- PAOUT =~0x18;delay_ms(500);
- PAOUT =~0x0C;delay_ms(500);
- PAOUT =~0x06;delay_ms(500);
- PAOUT =~0x03;delay_ms(500);
- }
- else if ((sw1==0)&&(sw2!=0)&&(sw3==0)&&(sw4==0))
- {
- PAOUT =~0x05;delay_ms(500);
- PAOUT =~0x0A;delay_ms(500);
- PAOUT =~0x14;delay_ms(500);
- PAOUT =~0x28;delay_ms(500);
- PAOUT =~0x50;delay_ms(500);
- PAOUT =~0xA0;delay_ms(500);
- }
- else if ((sw1!=0)&&(sw2!=0)&&(sw3==0)&&(sw4!=0))
- {
- PAOUT =~0x81;delay_ms(500);
- PAOUT =~0x42;delay_ms(500);
- PAOUT =~0x24;delay_ms(500);
- PAOUT =~0x18;delay_ms(500);
- }
- else if ((sw1==0)&&(sw2==0)&&(sw3==0)&&(sw4!=0))
- {
- PAOUT =~0x01;delay_ms(500);
- PAOUT =~0x03;delay_ms(500);
- PAOUT =~0x07;delay_ms(500);
- PAOUT =~0x0F;delay_ms(500);
- PAOUT =~0x1F;delay_ms(500);
- PAOUT =~0x3F;delay_ms(500);
- PAOUT =~0x7F;delay_ms(500);
- PAOUT =~0xFF;delay_ms(500);
- }
- else
- PAOUT =~0xFF;
- }
- }
- void delay_ms(unsigned int delay)
- {
- unsigned int x,y;
- for(x=0;x<=delay;x++)
- for(y=0;y<=512;y++);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement