organtin
Created May 22, 2018 © CC BY

A Geiger Counter Simulator

Build a device to safely teach radioactivity or to scare your buddies.

BeginnerFull instructions provided10,818
A Geiger Counter Simulator

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Relay Module (Generic)
This will be used just to make some noise when the relay switched from on to off and viceversa. Then, you shouldn't use a solid state relay.
×1

Story

Read more

Schematics

Schematic

Code

The Arduino sketch

Arduino
#define CLIK 8
#define ECHO 2
#define TRIG 3

#define c 340.e-6  // the speed of sound

void setup() {
  pinMode(CLIK, OUTPUT);
  pinMode(ECHO, INPUT);
  pinMode(TRIG, OUTPUT);
  digitalWrite(TRIG, LOW);
  digitalWrite(CLIK, LOW);
}

void trigger() {
  /* trigger the sensor */
  digitalWrite(TRIG, HIGH);
  delayMicroseconds(10);
  digitalWrite(TRIG, LOW);
}

float measure() {
  /* measure the distance between the sensor and the obstacle */
  float d = 0.;
  for (int i = 0; i < 15; i++) {
    trigger();
    unsigned long T = pulseIn(ECHO, HIGH);
    d += c*T/2.;
  }
  return d;
}

int status = HIGH; // the current status of the relay

void loop() {
  float d = measure();
  unsigned long trigger = 1000./(d*d); 
  unsigned long r = random(1000);
  if (r < trigger) {
    digitalWrite(CLIK, status);
    if (status == HIGH) {
      status = LOW;
    } else {
      status = HIGH;
    }
  }
}

Credits

organtin
1 project • 1 follower
Contact

Comments

Please log in or sign up to comment.