pastebin - collaborative debugging tool
kpaste.net RSS


Untitled
Posted by Anonymous on Wed 5th Sep 2012 04:23
raw | new post

  1. /*
  2. needs pin.c and pin.h  .
  3.  */
  4. #include <stdio.h>
  5. #include <propeller.h>
  6. #include "pin.h"
  7. /*
  8. void LowToHigh(){
  9.     int n = 16;
  10.     while(n < 23){
  11.         pinHigh(n);
  12.         waitcnt(CLKFREQ/100 + CNT);
  13.         pinLow(n);
  14.         n++;
  15.     }
  16. }
  17. void HighToLow(){
  18.     int n = 23;
  19.     while(n > 16){
  20.         pinHigh(n);
  21.         waitcnt(CLKFREQ/100 + CNT);
  22.         pinLow(n);
  23.         n--;
  24.     }
  25. }*/
  26.  
  27. int main()
  28. {
  29.     pinInput(2);
  30.     pinOutput(16);
  31.     pinOutput(17);
  32.     pinOutput(18);
  33.     pinOutput(19);
  34.     pinOutput(20);
  35.     pinOutput(21);
  36.     pinOutput(22);
  37.     pinOutput(23);
  38.     int change = 0;
  39.     while(1) {
  40.         int Sensor = pinGetField(1,2);
  41.         waitcnt(CLKFREQ/10+CNT);
  42.       //  printf("\ntest: %d\n\n", Sensor);
  43.         if (Sensor == 0){
  44.             printf("No Movement! :D\n");
  45.             if (change == 0){
  46.                 int n = 23;
  47.                 while(n > 16){
  48.                     pinHigh(n);
  49.                     waitcnt(CLKFREQ/10 + CNT);
  50.                     pinLow(n);    
  51.                     n--;
  52.                 }
  53.                 change = 1;
  54.             }
  55.             pinHigh(16);
  56.             waitcnt(CLKFREQ/10+CNT);
  57.             pinLow(16);
  58.         }
  59.         else if(Sensor == 1){
  60.             printf("OMG MOVEMENT!!!! D;\n");
  61.             if (change == 1){
  62.                 int n = 16;
  63.                 while(n < 23){
  64.                    pinHigh(n);
  65.                    waitcnt(CLKFREQ/10 + CNT);
  66.                    pinLow(n);
  67.                    n++;
  68.                 }
  69.                 change = 0;
  70.             }
  71.             pinHigh(23);
  72.             waitcnt(CLKFREQ/10+CNT);
  73.             pinLow(23);
  74.         }
  75.     }
  76.     return 0;
  77. }

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at