Advertisement
Guest User

Untitled

a guest
Sep 26th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.48 KB | None | 0 0
  1. #include "rims.h"
  2.  
  3. /* This is a sample program.  You can save/compile/run it,
  4.    modify it first, or just load a different program.      */
  5.  
  6. /* Sets B0 to 1 as quickly as possible when A0==1 and A1==0*/
  7.  
  8. /* Note that A0 - A7 can be set by clicking the switches to
  9.    the left, and B0 - B7 can be viewed as LEDs to the right
  10.    (green corresponds to '1', red to '0').                 */
  11.    
  12. volatile unsigned char TimerFlag=0; // ISR raises, main() lowers
  13.  
  14. void TimerISR() {
  15.    TimerFlag = 1;
  16. }
  17.  
  18. void DoTime(int time) //myFunction
  19. {
  20.   TimerSet(time);
  21.   TimerOn();
  22.   while(!TimerFlag){}
  23.   TimerFlag = 0;
  24. }  
  25.  
  26. char elBoolo = 1;
  27. char counter = 0;
  28.  
  29. void main()
  30. {
  31.    while (1) {
  32.     while(A0 && !A1)  
  33.        {
  34.         B = 0xFF;
  35.         DoTime(1000);
  36.         B = 0;
  37.         DoTime(1000);
  38.        }
  39.        
  40.     while(A1 && !A0)
  41.        {
  42.        B0 = 1;
  43.        
  44.            while(elBoolo == 1)
  45.            {
  46.                B = 1 << counter;
  47.                counter++;
  48.                
  49.                             if (counter == 7)
  50.                     {
  51.                         elBoolo = 0;
  52.                     }
  53.                     DoTime(500);
  54.            }
  55.            
  56.            while(elBoolo == 0)
  57.            {
  58.                B = 1 << counter;
  59.                counter--;
  60.                          if (counter == 0)
  61.                  {
  62.                      elBoolo = 1;
  63.                  }
  64.                     DoTime(500);
  65.            }
  66.        }
  67.        
  68.    }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement