pastebin - collaborative debugging tool
kpaste.net RSS


propeller c sensor
Posted by Anonymous on Wed 5th Sep 2012 02:33
raw | new post
view followups (newest first): propeller c sensor by Anonymous

  1. /*
  2.  * This is a non-traditional hello demo for Propeller-GCC.
  3.  * The demo repeats printing every 100ms with the iteration.
  4.  * It uses waitcnt instead of sleep so it will fit in a COG.
  5.  */
  6. #include <stdio.h>
  7. #include <propeller.h>
  8. #include "pin.h"
  9.  
  10. int main()
  11. {
  12.     pinInput(2);
  13.     pinOutput(16);
  14.     pinOutput(23);
  15.     while(1) {
  16.         int Sensor = pinGetField(1,2);
  17.         waitcnt(CLKFREQ/10+CNT);
  18.       //  printf("\ntest: %d\n\n", Sensor);
  19.         if (Sensor == 0){
  20.             printf("No Movement! :D\n");
  21.             pinHigh(16);
  22.             waitcnt(CLKFREQ/10+CNT);
  23.             pinLow(16);
  24.         }
  25.         else if(Sensor == 1){
  26.             printf("OMG MOVEMENT!!!! D;\n");
  27.             pinHigh(23);
  28.             waitcnt(CLKFREQ/10+CNT);
  29.             pinLow(23);
  30.         }
  31.     }
  32.     return 0;
  33. }

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