mitty
Published © GPL3+

Frozen Computer Alarm

Make an alarm sound when the computer stops working.

IntermediateShowcase (no instructions)4,325
Frozen Computer Alarm

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
Buzzer
Buzzer
×1

Hand tools and fabrication machines

Premium Female/Male Extension Jumper Wires, 40 x 6" (150mm)
Premium Female/Male Extension Jumper Wires, 40 x 6" (150mm)

Story

Read more

Schematics

circuit_uNyZKKfCd3.jpg

the compiled exe file of the Windows program

Code

Computer Program

VB.NET
Imports System.IO.Ports

Public Class Form1

    Dim port As SerialPort

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        port = New SerialPort("COM4", 9600) 'Set your board COM
        port.Open()
    End Sub

    Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
        port.Close()
    End Sub

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
        On Error GoTo error1
        port.Write("1") 'character to send to COM port, wich the Arduino will expect.
        Label1.Text = Now() & " - Sent ""1"" on COM4 baud 9600 - Success!"
        Exit Sub

error1:
        Label1.Text = Now() & " - " & ErrorToString()
    End Sub
	
End Class

Arduino Code

Arduino
char incomingChar = 0; // for incoming serial data
int NoSignalCounter = -60; // computer startup time

void setup() {
  Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
}

void loop() {
  while (Serial.available() > 0) {
    NoSignalCounter = 0;
    incomingChar = Serial.read();
    if (incomingChar == '1') { // '1' is the character expected from the computer
      noTone(10);
    }
    else {
      tone(10, 2400); // alarm: the character sent from the computer is different from the expected character
    }
  }
  NoSignalCounter++;
  if (NoSignalCounter >= 10) { // alarm: no character was received from the computer in the last 10 seconds
    NoSignalCounter = 0;
    tone(10, 2400); //(pin,frequency)
  }
  delay(1000);
}

Credits

mitty

mitty

0 projects • 2 followers

Comments