i need help stuck on this part

hello guys I am final year electrical engineering student
i am working on my FYP and the project i am making is brain controlled wheelchair using neurosky mindwave device as most of u have heard about.Now i have my device connected to MATLAB and in MATLAB i have coded to get the signal of eye blink strength, now i am getting these blink strength value now my other task is to send there values to arduino and i am doing that i am also getting values on arduino but the problem is on arduino i need to count the number of time i blink. before i was controlling the movement of wheelchair on different thresholds like if my blink strength value is between 50 to 75 i go forward if its value is between 75 to 100 i go right u get the point max value is 255 8 bits but what i want is to count number of blinks i do and from those i control my movement i have created the code using timers but it is not working as i wished it would please guide me how i use timers to make this code work or interrupts.Remember the my EGG sensor is connected to matlab. (English is not my strong suite)

 int Blinkstrenght;
int count = 0;
const int forward = 13; // these are just leds to imitate the movement right now
const int stopp    = 12;//led
const int left    = 11;//led
const int right   = 10;//led
const unsigned long interval=2000; // the time we need to wait
unsigned long previousMillis=0; // millis() 


void setup()
{
Serial.begin(9600);
pinMode(forward, OUTPUT); // declaring outputs
pinMode(stopp, OUTPUT);
pinMode(left, OUTPUT);
pinMode(right, OUTPUT);

}

void loop()
{
  if(Serial.available()>0) // here i am getting value from MATLAB 
  {
    Blinkstrenght=Serial.read(); // saving values from 0 to 255 in blinkstrength variable the values depend on how hard i blink or how soft 

    
    
     
    if (Blinkstrenght > 55 && Blinkstrenght < 100 ) // here i am considering if my blink value is between 55 to 100 i increment the counter to imitate blink counts        
    { 
    count = count + 1;
    unsigned long currentMillis = millis();      // frm this part i am lost guide me please using timer0 but nothing is working the way i want to 
     if ((currentMillis - previousMillis) >= interval) 
     {
      while(count){
       if (count == 1)
      {
        digitalWrite(forward, HIGH);
    digitalWrite(stopp,LOW);
    digitalWrite(left ,HIGH);
    digitalWrite(right,LOW);
    previousMillis +=interval;
    break;
    
   
      }
      if (count ==2)
      {
        digitalWrite(forward, LOW);
    digitalWrite(stopp,LOW);
    digitalWrite(left ,LOW);
    digitalWrite(right,LOW);
    previousMillis +=interval;
    break;
    
      }
      if (count == 3)
      {
        digitalWrite(forward, LOW);
    digitalWrite(stopp,LOW);
    digitalWrite(left ,HIGH);
    digitalWrite(right,LOW);
    previousMillis +=interval;
    break;
    
      }
      if (count == 4)
      {
        digitalWrite(forward, LOW);
    digitalWrite(stopp,LOW);
    digitalWrite(left ,LOW);
    digitalWrite(right,HIGH);
    previousMillis +=interval;
    break;
    
      }
     
     }
    }
    }
    
    
   
    if ( Blinkstrenght > 100)
    {
      count = 0;
    }
  
}
}

Hi,
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".
OR
http://forum.arduino.cc/index.php/topic,148850.0.html.
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

I have edited your post to help with your English.

Hello guys I am final year electrical engineering student.
I am working on my FYP and the project I am making is brain controlled wheelchair using neurosky mindwave device as most of you have heard about.
Now I have my device connected to MATLAB and in MATLAB I have coded to get the signal of eye blink strength.
Now I am getting these blink strength value.
Now my other task is to send there values to arduino and I am doing that.
I am also getting values on arduino but the problem is on arduino I need to count the number of times I blink.
Before I was controlling the movement of wheelchair on different thresholds like if my blink strength value is between 50 to 75.
I go forward if its value is between 75 to 100 I go right you get the point max value is 255 8 bits.

But what I want is to count number of blinks I do and from those I control my movement.

I have created the code using timers but it is not working as I wished it would.
Please guide me how I use timers to make this code work or interrupts.
Remember the my EGG sensor is connected to matlab. (English is not my strong suite)

If you cannot post your code in code tags because it is too big.
Please attach it as an .ino file.

Thanks.. Tom... :slight_smile:

thanks alot sir

Also a good title other than "I need Help" seems to work better - not everyone reads every post and a good title helps someone to decide if they want to help you or not - or even if they have the knowledge to help you with your project.

Good luck

Proper English, spelling, capitalization and grammar also go a long way to communicating. I am not too keen to assist someone who is too lazy to type out "you" or capitalize "I".

Grammatically your question is almost unreadable consisting of three run-on sentences.

English may not be your "strong suite", but not learning sentence construction is definitely going to be an obstacle to your engineering career.

If you wish to count blinks to determine the command instead of using the strength of a blink, how do you plan to distinguish between one blink, then a pause, and then two blinks, from a three blink command?

Can the blink counting be done in Matlab, since it is actually determining if there was a blink, and the number of blinks transmitted by Serial to the Arduino, or does the counting need to be done on the Arduino?