FSR sensor to stop servo

hello
im using neurosky mindwave to control with servo by attention and meditation to run servo
and i have FSR sensor to stop these servo
can any one help me this is my code below and need to insert the FSR to stop servo on any thing touch it please write to me the code :

#include <Servo.h>
#define BAUDRATE 57600
#define DEBUGOUTPUT 0
#define powercontrol 10
// servo motors
Servo index;
Servo thumb;
// checksum variables
byte generatedChecksum = 0;
byte checksum = 0;
int payloadLength = 0;
byte payloadData[64] = {30};
byte poorQuality = 0;
byte attention = 0;
byte meditation = 0;
// system variables
long lastReceivedPacket = 0;
boolean bigPacket = false;
//////////////////////////
// Microprocessor Setup //
//////////////////////////
void setup() {
Serial.begin(BAUDRATE); // USB
index.attach(13);
palm.attach(9);
}
////////////////////////////////
// Read data from Serial UART //
////////////////////////////////
byte ReadOneByte() {
int ByteRead;
while(!Serial.available());
ByteRead = Serial.read();
#if DEBUGOUTPUT
Serial.print((char)ByteRead); // echo the same byte out the USB serial (for debug
purposes)
#endif
return ByteRead;
}
/////////////
//MAIN LOOP//
/////////////
void loop() {
// Look for sync bytes
if(ReadOneByte() == 170) {
if(ReadOneByte() == 170) {
  payloadLength = ReadOneByte();
if(payloadLength > 169) //Payload length can not be greater than 169

return;
generatedChecksum = 0;
for(int i = 0; i < payloadLength; i++) {
payloadData[i] = ReadOneByte(); //Read payload into memory
generatedChecksum += payloadData[i];
}
checksum = ReadOneByte(); //Read checksum byte from stream
generatedChecksum = 255 - generatedChecksum; //Take one's compliment of generated checksum

if(checksum == generatedChecksum) {
poorQuality = 200;
attention = 0;
meditation = 0;
for(int i = 0; i < payloadLength; i++) { // Parse the payload
switch (payloadData[i]) {
case 2:
i++;
poorQuality = payloadData[i];
bigPacket = true;
break;
case 4:
i++;
attention = payloadData[i];
break;
case 5:
i++;
meditation = payloadData[i];
break;
case 0x80:
i = i + 3;
break;
case 0x83:
i = i + 25;
break;
default:
break;
} // switch
} // for loop
#if !DEBUGOUTPUT
if(bigPacket) {
if (attention >= 60) {
Serial.print("Over 80; ");
index.write(10);
}
else {
Serial.print("Under 80; ");
index.write(170);
}
if  (meditation >=80) 
  {
 palm.write(10);}
 else{
  palm.write(175);

 }
Serial.print("PoorQuality: ");
Serial.print(poorQuality, DEC);
Serial.print("  Attention: ");
Serial.print(attention, DEC);
Serial.print (" Meditation:"); 
 Serial.print (meditation,DEC); 
Serial.print(" Time since last packet: ");
Serial.print(millis() - lastReceivedPacket, DEC);
lastReceivedPacket = millis();
Serial.print("\n");
}
#endif
bigPacket = false;
}
else {
  // Checksum Error
} // end if else for checksum
} // end if read 0xAA byte
} // end if read 0xAA byte
}

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

sketch_dec12a.ino (2.57 KB)

We do not write code for people here. If you want code written for you, have a moderator move this post to the Gigs and Collaborations section. Expect to pay. If you make an attempt at writing the code an post it properly along with an description of what it does and how that differs form what you want the code to do, we can help you to get it working.

Please read the "how to use this forum-please read" stickies to see how to format and post code. Properly posted code will not be turned into italics and will be properly indented. Poorly indented code is very hard to read.

hello
im using neurosky mindwave to control with servo by attention and meditation to run servo
and i have FSR sensor to stop these servo
can any one help me this is my code below and need to insert the FSR to stop servo on any thing touch it please write to me the code :

#include <Servo.h>
#define BAUDRATE 57600
#define DEBUGOUTPUT 0
#define powercontrol 10
// servo motors
Servo index;
Servo middle;
Servo ring;
Servo little;
Servo palm;
Servo thumb;
// checksum variables
byte generatedChecksum = 0;
byte checksum = 0;
int payloadLength = 0;
byte payloadData[64] = {30};
byte poorQuality = 0;
byte attention = 0;
byte meditation = 0;
// system variables
long lastReceivedPacket = 0;
boolean bigPacket = false;
//////////////////////////
// Microprocessor Setup //
//////////////////////////
void setup() {
Serial.begin(BAUDRATE); // USB
index.attach(13);
palm.attach(9);
}
////////////////////////////////
// Read data from Serial UART //
////////////////////////////////
byte ReadOneByte() {
int ByteRead;
while(!Serial.available());
ByteRead = Serial.read();
#if DEBUGOUTPUT
Serial.print((char)ByteRead); // echo the same byte out the USB serial (for debug
purposes)
#endif
return ByteRead;
}
/////////////
//MAIN LOOP//
/////////////
void loop() {
// Look for sync bytes
if(ReadOneByte() == 170) {
if(ReadOneByte() == 170) {
  payloadLength = ReadOneByte();
if(payloadLength > 169) //Payload length can not be greater than 169

return;
generatedChecksum = 0;
for(int i = 0; i < payloadLength; i++) {
payloadData[i] = ReadOneByte(); //Read payload into memory
generatedChecksum += payloadData[i];
}
checksum = ReadOneByte(); //Read checksum byte from stream
generatedChecksum = 255 - generatedChecksum; //Take one's compliment of generated checksum

if(checksum == generatedChecksum) {
poorQuality = 200;
attention = 0;
meditation = 0;
for(int i = 0; i < payloadLength; i++) { // Parse the payload
switch (payloadData[i]) {
case 2:
i++;
poorQuality = payloadData[i];
bigPacket = true;
break;
case 4:
i++;
attention = payloadData[i];
break;
case 5:
i++;
meditation = payloadData[i];
break;
case 0x80:
i = i + 3;
break;
case 0x83:
i = i + 25;
break;
default:
break;
} // switch
} // for loop
#if !DEBUGOUTPUT
if(bigPacket) {
if (attention >= 60) {
Serial.print("Over 80; ");
index.write(10);
}
else {
Serial.print("Under 80; ");
index.write(170);
}
if  (meditation >=80) 
  {
 palm.write(10);}
 else{
  palm.write(175);

 }
Serial.print("PoorQuality: ");
Serial.print(poorQuality, DEC);
Serial.print("  Attention: ");
Serial.print(attention, DEC);
Serial.print (" Meditation:"); 
 Serial.print (meditation,DEC); 
Serial.print(" Time since last packet: ");
Serial.print(millis() - lastReceivedPacket, DEC);
lastReceivedPacket = millis();
Serial.print("\n");
}
#endif
bigPacket = false;
}
else {
  // Checksum Error
} // end if else for checksum
} // end if read 0xAA byte
} // end if read 0xAA byte
}

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

sketch_dec12a.ino (2.57 KB)

OP posted there already: [MERGED] FSR sensor to stop servo - Sensors - Arduino Forum

im using neurosky mindwave to control with servo by attention and meditation to run servo

Which servo? index? middle? rung? little? palm? thumb?

What pin is the FSR connected to? Where do you read that pin?

You realize, I hope, that since you only tell any given servo to go to some new position IN ONE STEP, that you won't be able to stop the servo until it completes that step.

@alialhassany93, stop cross-posting. Threads merged.

hi
ihave a neurosky mindwave .and ineed a code for arduino consist both eye blink and attention to control servo motors . please any one help me

@alialhassany93, stop cross-posting.

hi
can any one help i need acode for arduino control the servo motors with neurosky mind wave and ihave only the code for single eye blink . can any one help me and talk to me change in code and make the code for single and double eye blink

eye_code.ino (3.02 KB)

hi
ineed acode for arduino consist eye blink +attention +medetion for neurosky togother

What?

-jim lee

Moderator: merged all your 5 threads, do not cross post again.