Tags:
Álbuns: Ponto Zero da Fase
Comentar
int D = 2; // o delay de controle
const int sensor = 2; // Pino de leitura do opto
const int controle = 13; // Pino ligado ao circuito do Triac
//este pino tem que disparar em [To+T/16] para que o motor tenha 7T/8 da potencia total
// Variables will change:
int sensorState = 0; // Estado do opto. Se estiver HIGH, tensao diferente de zero.
//Se estiver em LOW, tensao = zero. Presisamente o que queremos.
int lastSensorState = 0; // O estado anterior do sensor.
void setup() {
// initialize the button pin as a input:
pinMode(sensor, INPUT);
// initialize the LED as an output:
pinMode(controle, OUTPUT);
// initialize serial communication:
Serial.begin(9600);
}
void loop() {
digitalWrite(controle, HIGH);
// read the pushbutton input pin:
sensorState = digitalRead(sensor);
// compare the buttonState to its previous state
if (sensorState != lastSensorState) {
{
}
// if the state has changed, increment the counter
if (sensorState == HIGH) {
digitalWrite(controle, LOW);
delay(D);
digitalWrite(controle, HIGH);
Serial.print("|");
}
else {
// if the current state is LOW then the button
// wend from on to off:
Serial.print(".");
}
}
}
Bem-vindo a
Laboratorio de Garagem (arduino, eletrônica, robotica, hacking)
© 2024 Criado por Marcelo Rodrigues. Ativado por
Você precisa ser um membro de Laboratorio de Garagem (arduino, eletrônica, robotica, hacking) para adicionar comentários!
Entrar em Laboratorio de Garagem (arduino, eletrônica, robotica, hacking)