Go Down

Topic: encoder (Read 16 times) previous topic - next topic

mem

I was hoping that you could describe what task you have for your application without reference to code.

I don't understand if you want to use two arduinos because you think one is not capable of doing what you want or if there is some reason you want to use two that you haven't explained.

I also do not understand the relationship between the thresholds and the encoder counts.

It seems to me that your descriptions contain a little bit of what you want to do and a little bit of how you want to do it. But there is not enough of either for me to get a clear enough idea of the purpose of your application so I can  guide you.

So it would really help me to help you if you could think about describing what actions you want your application to perform as the count thresholds are reached,  before speculating about how it could be implimented.

mem

It will help me understand if you can explain what you said in the previous post but pretend that there is just one arduiono. I am not saying you shouldn't use two (although I don't understand why you are) but I am getting confused by the stuff you are doing to talk from one to the other.

So, pretend that your entire application was implemented on only one board, what do you want the LED to do when the count reaches a specified number? Should anything else also happen at this time.  And what should happen after that

mingki

#42
Feb 09, 2008, 04:32 pm Last Edit: Feb 09, 2008, 04:34 pm by mingki Reason: 1
i want the analog input(from potentiameter) act as a commend to initialize the encoder count for specified steps.
when the specified steps reached, i want the corresponding LED flashed. that's what i want to do.  

mem

try something like this:

int startCount;
int steps

startCount = encoder0Pos;   // put this in setup();


// and this in your loop
steps = analogRead(potpin) / 25 ;   //  this gives 40 steps, a pot value of 1023 = 40
if(encoder0Pos > startCount + steps){  
   startCount = encoder0Pos;  // I assume you want to reset the counter
   digitalWrite(13, HIGH);       // flash an LED
   delay(1000);  
   digitalWrite(13, HIGH);
}

mingki

#44
Feb 10, 2008, 06:19 am Last Edit: Feb 10, 2008, 06:25 am by mingki Reason: 1
I tried your sketch like the following.
void loop(){
 steps = analogRead(0) / 25;        
 if (val > 1 && val < 20)
 {
   if(encoder0Pos > startCount + steps){  
     startCount = encoder0Pos;
     digitalWrite(3, HIGH);
     delay(1000);
     digitalWrite(3, LOW);
     delay(1000);
   }
 }
but,  #3 digtal pin LED doesn't flash.



Go Up