Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <msp430x14x.h>
- int btn1pressed()
- {
- if(P4IN == 0x10)
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
- int btn2pressed()
- {
- if(P4IN == 0x20)
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
- int btn3pressed()
- {
- if(P4IN == 0x40)
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
- int btn4pressed()
- {
- if(P4IN == 0x80)
- {
- return 1;
- }
- else
- {
- return 0;
- }
- }
- void delay(int x)
- {
- int count;
- for (count = 0; count < x; count++);
- }
- void main()
- {
- WDTCTL = WDTPW + WDTHOLD;
- P4DIR=12;
- while(1)
- {
- if(btn1pressed())
- {
- delay(400);
- }
- if(btn2pressed())
- {
- delay(500);
- }
- if(btn3pressed())
- {
- delay(600);
- }
- if(btn4pressed())
- {
- delay(700);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement