Prepara
Coloca o Arduino e a breadboard numa superfície estável. Nunca apontes o laser para os olhos.
PontoTi
A ligar sistemas
Arduino UNO · interruption sensor
Um feixe de luz torna-se uma fronteira. Quando alguém o interrompe, o Arduino regista o evento, activa o alarme e espera por uma decisão humana.
Começar a construir ↓01 / overview
O módulo laser mantém o feixe no sensor. A interrupção dispara uma interrupção no Arduino; o alarme fica activo até o botão de reset ser premido.
Coloca o Arduino e a breadboard numa superfície estável. Nunca apontes o laser para os olhos.
Segue a tabela de ligações. O LDR deve receber luz constante enquanto o sistema está armado.
Abre o ficheiro `.ino` no Arduino IDE e selecciona Arduino UNO e a porta USB.
Interrompe o feixe com a mão. O LED vermelho e o buzzer devem activar-se.
02 / wiring
03 / bill of materials
Uma lista inicial para a montagem. Os botões de compra ficam preparados para uma futura integração de catálogo, sem URLs comerciais inventados.
04 / firmware
O editor mostra exactamente o mesmo conteúdo que podes descarregar. Sem cópias visuais divergentes.
const byte LASER_PIN = 2;
const byte LDR_PIN = A0;
const byte LED_GREEN = 8;
const byte LED_RED = 9;
const byte BUZZER_PIN = 10;
const byte RESET_PIN = 7;
volatile bool beamBroken = false;
bool alarmActive = false;
void beamInterrupted() {
beamBroken = true;
}
void setup() {
pinMode(LASER_PIN, INPUT_PULLUP);
pinMode(LED_GREEN, OUTPUT);
pinMode(LED_RED, OUTPUT);
pinMode(BUZZER_PIN, OUTPUT);
pinMode(RESET_PIN, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(LASER_PIN), beamInterrupted, FALLING);
digitalWrite(LED_GREEN, HIGH);
}
void loop() {
if (beamBroken) {
alarmActive = true;
beamBroken = false;
}
if (digitalRead(RESET_PIN) == LOW) {
alarmActive = false;
noTone(BUZZER_PIN);
}
digitalWrite(LED_GREEN, !alarmActive);
digitalWrite(LED_RED, alarmActive);
if (alarmActive) tone(BUZZER_PIN, 880);
delay(20);
}05 / verify
Confirma que o sensor está protegido de luz ambiente e que o laser está alinhado com o LDR.
Verifica a polaridade: a perna longa é o ânodo. Usa sempre uma resistência de 220 Ω.
O botão deve ligar D7 ao GND e usar `INPUT_PULLUP`; confirma a ligação sem resistência externa.