Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <REGX51.H>
- #include <intrins.h> // do _nop_
- #define TRUE 1
- void przycisk(void) interrupt 0 {// dzialanie po wcisnieciu
- P1++;
- }
- void setup(void){
- P1 = 0x00;
- EX0 = 1;
- IT0 = 1; // detekcja zbocza opadajacego ( nie wykrycie stanu niskiego )
- EA = 1;
- }
- void delay(unsigned char ms) // opuzniacz na zasadzie instrukcji nop{
- unsigned long us = 1000 * ms;
- while (us--)
- _nop_();
- }
- void dioda(){
- if(P1%2 == 0){
- P0_0 = 0x00;
- P2_0 = 0x00;
- delay(5);
- P0_0 = 0x01;
- P2_0 = 0x01;
- delay(5);
- }
- else{
- P0_0 = 0x01;
- P2_0 = 0x00;
- }
- }
- void main(void){
- setup();
- while (TRUE)
- dioda();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement