Difference between
modified post dbc817677 by Anonymous on Wed 5th Sep 2012 02:50
original post 3ad6c7c086 by Anonymous on Wed 5th Sep 2012 02:33
Download diff
Show
old version |
new version |
both versions
| 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 | 1 | #include <stdio.h> | |
| 7 | 2 | #include <propeller.h> | |
| 8 | 3 | #include "pin.h" | |
| 9 | 4 | ||
| 10 | 5 | int main() | |
| 11 | 6 | { | |
| 12 | 7 | pinInput(2); | |
| 13 | 8 | pinOutput(16); | |
| 14 | 9 | pinOutput(23); | |
| 15 | 10 | while(1) { | |
| 16 | 11 | int Sensor = pinGetField(1,2); | |
| 17 | 12 | waitcnt(CLKFREQ/10+CNT); | |
| 18 | 13 | // printf("\ntest: %d\n\n", Sensor); | |
| 19 | 14 | if (Sensor == 0){ | |
| 20 | 15 | printf("No Movement! :D\n"); | |
| 21 | 16 | pinHigh(16); | |
| 22 | 17 | waitcnt(CLKFREQ/10+CNT); | |
| 23 | 18 | pinLow(16); | |
| 24 | 19 | } | |
| 25 | 20 | else if(Sensor == 1){ | |
| 26 | 21 | printf("OMG MOVEMENT!!!! D;\n"); | |
| 27 | 22 | pinHigh(23); | |
| 28 | 23 | waitcnt(CLKFREQ/10+CNT); | |
| 29 | 24 | pinLow(23); | |
| 30 | 25 | } | |
| 31 | 26 | } | |
| 32 | 27 | return 0; | |
| 33 | 28 | } | |
| 34 | 29 |
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.
kpaste.net RSS