Montei um esquema aqui no arduino e não funfa, não sei por que to boiando. Alguem sabe por que o led não pisca?

const int portaGnd = 4;
const int portaOut = 3;
const int portaVcc = 2;

int contador = 0;
int led = 9;

void setup()
{
pinMode(portaGnd, OUTPUT);
pinMode(portaOut, INPUT);
pinMode(portaVcc, OUTPUT);
pinMode(led,OUTPUT);
digitalWrite(portaGnd, LOW);
digitalWrite(portaOut, LOW);
digitalWrite(portaVcc, HIGH);
Serial.begin(9600);
}

void loop()
{
int x = digitalRead(portaOut);
if (x == HIGH)
{
// houve movimento
Serial.print("Movimento detectado: ");
Serial.println(contador);
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(10);
contador++;


}

delay(100);
}

Exibições: 158

Responder esta

© 2024   Criado por Marcelo Rodrigues.   Ativado por

Badges  |  Relatar um incidente  |  Termos de serviço