ola amigos estou com erro amigos  podeira me ajudar gostaria de controlar 2 rele com 2 poenciomeros  

mais esse codigo contem  erros se possivel   alguem poderia me dizer aonde q eu estou errando   ficarei agradeçido a todos  por me ajudar !

int targetPin = A2;// select the input pin for distance sensor or potentiometer
int actualPin = A0;// select the input pin for the potentiometer attached to the ram
int outSol = 12; //digital pin with the solenoid that forces the ram out
int inSol = 11; //digital pin with the solenoid that forces the ram in
int actualRange = 838; // range of the potentiometer attached to the ram -test it with serial out)
int targetRange = 650;
int pollDelay = 60; //how fast to cycle, figgure out how fast your valves will cycle, I am using 5-10ms valves
int fuzzyFactor = 100; //how close the two values need to match

int targetValue = 0; // variable to store the value coming from the sensor
int targetValueLow = 0;
int targetValueHigh = 0;
int actualValue = 0;

void setup() { // declare the solenoid pins as outputs
pinMode(outSol, OUTPUT);
pinMode(inSol, OUTPUT);
Serial.begin(9600);}

void loop() {
pollDelay = random(80,120); //generate a random delay between sensor checks

// read the values from the sensors:
targetValue = analogRead(targetPin);
actualValue = analogRead(actualPin);

actualValue = map(actualValue, 0, actualRange, 0, 1023); //remap to whole range
targetValue = map(targetValue, 0, targetRange, 1023, 0); //remap to whole range and invert

Serial.println(actualValue); //write stuff to the serial for debugging
Serial.println(targetValue);

//Set up the value range thats acceptable
targetValueLow = targetValue - fuzzyFactor;
targetValueHigh = targetValue + fuzzyFactor;

if (argetValue < fuzzyFactor)
//if the goal is full retract lock the ram there {
digitalWrite (outSol, LOW);
digitalWrite (inSol, HIGH);
Serial.println ("Case 1");
}

else if (targetValue > (1023 - fuzzyFactor))
{//if goal is full extend lock the ram there
digitalWrite (outSol, HIGH);
digitalWrite (inSol, LOW);
Serial.println ("Case 2");
}

else {
//if the ram is close enough to the goal apply air to both sides
digitalWrite (outSol, HIGH);
digitalWrite (inSol, HIGH);
Serial.println ("Case 3");
}
else if (actualValue < targetValue){
//if its less than the target extend
digitalWrite (outSol,HIGH);
digitalWrite (inSol, LOW);
Serial.println ("Case 4");
}

else {
//if more than target retract
digitalWrite (outSol, LOW);
digitalWrite (inSol, HIGH);
Serial.println ("Case 5");}
delay(pollDelay);
}

Exibições: 1346

Respostas a este tópico

Bruno, faltou o principal. O Erro.

Manda o log de erros também.

Mas de cara eu já vi uns erros de digitação nesse código...

logs  

sketch_aug18a.ino: In function 'void loop()':

sketch_aug18a:37: error: 'argetValue' was not declared in this scope
sketch_aug18a.ino: At global scope:
sketch_aug18a:44: error: expected unqualified-id before 'else'
sketch_aug18a:51: error: expected unqualified-id before 'else'
sketch_aug18a:54: error: expected constructor, destructor, or type conversion before '(' token
sketch_aug18a:55: error: expected constructor, destructor, or type conversion before '.' token
sketch_aug18a:56: error: expected declaration before '}' token 

o que   mais em e erro  me desculpa nao sou muio bom em programaçao  agradeço a sua ajuda !

só para começar:

arget é muito diferente de Target.

Indeed... LOL

RSS

© 2024   Criado por Marcelo Rodrigues.   Ativado por

Badges  |  Relatar um incidente  |  Termos de serviço