A parte de hardware esta toda ok e funcionando, mas a parte lógica não esta funcionando. Alguém consegue dar uma luz?
Segue:
#include <Servo.h>
Servo servomotor;
int indutivo = 4;
int otico = 7;
int tipomaterial;
int indutivoaux;
int oticoaux
void setup() {
servomotor.attach(3);
pinMode(indutivo, INPUT);
pinMode(otico, INPUT);
Serial.begin(9600);
}
void loop() {
if (digitalRead(indutivo) == HIGH)
{
indutivoaux = 10;
}
if (digitalRead(otico) == HIGH)
{
oticoaux = 10;
}
if ( (indutivoaux == 10) && (oticoaux == 10) )
{
tipomaterial = 10;
}
if ( (indutivoaux == 0) && (oticoaux == 10) )
{
tipomaterial = 20;
}
Serial.print(tipomaterial);
if(tipomaterial == 10)
{
indutivoaux = 0;
oticoaux = 0;
delay(100);
servomotor.write(70);
}
if(tipomaterial == 20)
{
indutivoaux = 0;
oticoaux = 0;
delay(100);
servomotor.write(130);
}
if ( (tipomaterial == 10) || (tipomaterial == 20) )
{
delay(3000);
tipomaterial = 0;
}
}