- /*
- needs pin.c and pin.h .
- */
- #include <stdio.h>
- #include <propeller.h>
- #include "pin.h"
- /*
- void LowToHigh(){
- int n = 16;
- while(n < 23){
- pinHigh(n);
- waitcnt(CLKFREQ/100 + CNT);
- pinLow(n);
- n++;
- }
- }
- void HighToLow(){
- int n = 23;
- while(n > 16){
- pinHigh(n);
- waitcnt(CLKFREQ/100 + CNT);
- pinLow(n);
- n--;
- }
- }*/
- int main()
- {
- pinInput(2);
- pinOutput(16);
- pinOutput(17);
- pinOutput(18);
- pinOutput(19);
- pinOutput(20);
- pinOutput(21);
- pinOutput(22);
- pinOutput(23);
- int change = 0;
- while(1) {
- int Sensor = pinGetField(1,2);
- waitcnt(CLKFREQ/10+CNT);
- // printf("\ntest: %d\n\n", Sensor);
- if (Sensor == 0){
- if (change == 0){
- int n = 23;
- while(n > 16){
- pinHigh(n);
- waitcnt(CLKFREQ/10 + CNT);
- pinLow(n);
- n--;
- }
- change = 1;
- }
- pinHigh(16);
- waitcnt(CLKFREQ/10+CNT);
- pinLow(16);
- }
- else if(Sensor == 1){
- if (change == 1){
- int n = 16;
- while(n < 23){
- pinHigh(n);
- waitcnt(CLKFREQ/10 + CNT);
- pinLow(n);
- n++;
- }
- change = 0;
- }
- pinHigh(23);
- waitcnt(CLKFREQ/10+CNT);
- pinLow(23);
- }
- }
- return 0;
- }
Untitled
Posted by Anonymous on Wed 5th Sep 2012 04:23
raw | new post
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.