This is my Arduino GeigerCounter with Neon Tube and LED Matrix display.
YouTube:
Schematic:
CIRCUIT:
R6=1kohm (was 1Mohm).
In the circuit: LED1 : if on the circuit is oscillating and ready to detect radiation.
LED2 : blinks and the speaker "clicks" . If not turn R5 (1Mohm) until it does. If not there is radiation --> start to run :-)
CHANGES: (08-06-2019) : I replaced BC550C with 2N2222, 1,8nF with 3,9nF/200V, 4,7nF with 100nF, R6=1k by 1Mohm. Now the circuit gives more clicks if there is more radiation. (I simulated the radiation with a 100kohm resistor over the neon tube). My neon tube: 4mm diameter and 9mm height. Setpoint of 1Mohm variable resistor: 53V over neon tube (76V neon tube lights up).
CODE:
In the Arduino-code, use the "turn" (0..3) to choose your LED Matrix module configuration.
"Invert" (0..1) to change the look.
COPY AND PASTE:
Arduino (uno) code: (copy and paste)
#include <LedControl.h>
#include <SoftwareSerial.h>
//We always have to include the library
//#include "LedControl.h"
//#include <avr/pgmspace.h>
//pin 11 is connected to the DataIn
//pin 13 is connected to the CLK
//pin 10 is connected to LOAD
//LedControl(int dataPin, int clkPin, int csPin, int numDevices);
LedControl lc = LedControl(11, 13, 10, 4);
byte dc = lc.getDeviceCount();
const unsigned char CH[] = {
//const unsigned char PROGMEM CH[] = {
//#define CH {
3, 8, B00000000, B00000000, B00000000, B00000000, B00000000, // space (starts at dec = 32)
1, 8, B01011111, B00000000, B00000000, B00000000, B00000000, // !
3, 8, B00000011, B00000000, B00000011, B00000000, B00000000, // "
5, 8, B00010100, B00111110, B00010100, B00111110, B00010100, // #
4, 8, B00100100, B01101010, B00101011, B00010010, B00000000, // $
5, 8, B01100011, B00010011, B00001000, B01100100, B01100011, // %
5, 8, B00110110, B01001001, B01010110, B00100000, B01010000, // &
1, 8, B00000011, B00000000, B00000000, B00000000, B00000000, // '
3, 8, B00011100, B00100010, B01000001, B00000000, B00000000, // (
3, 8, B01000001, B00100010, B00011100, B00000000, B00000000, // )
5, 8, B00101000, B00011000, B00001110, B00011000, B00101000, // *
5, 8, B00001000, B00001000, B00111110, B00001000, B00001000, // +
2, 8, B10110000, B01110000, B00000000, B00000000, B00000000, // ,
4, 8, B00001000, B00001000, B00001000, B00001000, B00000000, // -
2, 8, B01100000, B01100000, B00000000, B00000000, B00000000, // .
4, 8, B01100000, B00011000, B00000110, B00000001, B00000000, // /
4, 8, B00111110, B01000001, B01000001, B00111110, B00000000, // 0
3, 8, B01000010, B01111111, B01000000, B00000000, B00000000, // 1
4, 8, B01100010, B01010001, B01001001, B01000110, B00000000, // 2
4, 8, B00100010, B01000001, B01001001, B00110110, B00000000, // 3
4, 8, B00011000, B00010100, B00010010, B01111111, B00000000, // 4
4, 8, B00100111, B01000101, B01000101, B00111001, B00000000, // 5
4, 8, B00111110, B01001001, B01001001, B00110000, B00000000, // 6
4, 8, B01100001, B00010001, B00001001, B00000111, B00000000, // 7
4, 8, B00110110, B01001001, B01001001, B00110110, B00000000, // 8
4, 8, B00000110, B01001001, B01001001, B00111110, B00000000, // 9
2, 8, B01010000, B00000000, B00000000, B00000000, B00000000, // :
2, 8, B10000000, B01010000, B00000000, B00000000, B00000000, // ;
3, 8, B00010000, B00101000, B01000100, B00000000, B00000000, // <
3, 8, B00010100, B00010100, B00010100, B00000000, B00000000, // =
3, 8, B01000100, B00101000, B00010000, B00000000, B00000000, // >
4, 8, B00000010, B01011001, B00001001, B00000110, B00000000, // ?
5, 8, B00111110, B01001001, B01010101, B01011101, B00001110, // @
4, 8, B01111110, B00010001, B00010001, B01111110, B00000000, // A
4, 8, B01111111, B01001001, B01001001, B00110110, B00000000, // B
4, 8, B00111110, B01000001, B01000001, B00100010, B00000000, // C
4, 8, B01111111, B01000001, B01000001, B00111110, B00000000, // D
4, 8, B01111111, B01001001, B01001001, B01000001, B00000000, // E
4, 8, B01111111, B00001001, B00001001, B00000001, B00000000, // F
4, 8, B00111110, B01000001, B01001001, B01111010, B00000000, // G
4, 8, B01111111, B00001000, B00001000, B01111111, B00000000, // H
3, 8, B01000001, B01111111, B01000001, B00000000, B00000000, // I
4, 8, B00110000, B01000000, B01000001, B00111111, B00000000, // J
4, 8, B01111111, B00001000, B00010100, B01100011, B00000000, // K
4, 8, B01111111, B01000000, B01000000, B01000000, B00000000, // L
5, 8, B01111111, B00000010, B00001100, B00000010, B01111111, // M
5, 8, B01111111, B00000100, B00001000, B00010000, B01111111, // N
4, 8, B00111110, B01000001, B01000001, B00111110, B00000000, // O
4, 8, B01111111, B00001001, B00001001, B00000110, B00000000, // P
4, 8, B00111110, B01000001, B01000001, B10111110, B00000000, // Q
4, 8, B01111111, B00001001, B00001001, B01110110, B00000000, // R
4, 8, B01000110, B01001001, B01001001, B00110010, B00000000, // S
5, 8, B00000001, B00000001, B01111111, B00000001, B00000001, // T
4, 8, B00111111, B01000000, B01000000, B00111111, B00000000, // U
5, 8, B00001111, B00110000, B01000000, B00110000, B00001111, // V
5, 8, B00111111, B01000000, B00111000, B01000000, B00111111, // W
5, 8, B01100011, B00010100, B00001000, B00010100, B01100011, // X
5, 8, B00000111, B00001000, B01110000, B00001000, B00000111, // Y
4, 8, B01100001, B01010001, B01001001, B01000111, B00000000, // Z
2, 8, B01111111, B01000001, B00000000, B00000000, B00000000, // [
4, 8, B00000001, B00000110, B00011000, B01100000, B00000000, // \ backslash
2, 8, B01000001, B01111111, B00000000, B00000000, B00000000, // ]
3, 8, B00000010, B00000001, B00000010, B00000000, B00000000, // hat
4, 8, B01000000, B01000000, B01000000, B01000000, B00000000, // _
2, 8, B00000001, B00000010, B00000000, B00000000, B00000000, // `
4, 8, B00100000, B01010100, B01010100, B01111000, B00000000, // a
4, 8, B01111111, B01000100, B01000100, B00111000, B00000000, // b
4, 8, B00111000, B01000100, B01000100, B00101000, B00000000, // c
4, 8, B00111000, B01000100, B01000100, B01111111, B00000000, // d
4, 8, B00111000, B01010100, B01010100, B00011000, B00000000, // e
3, 8, B00000100, B01111110, B00000101, B00000000, B00000000, // f
4, 8, B10011000, B10100100, B10100100, B01111000, B00000000, // g
4, 8, B01111111, B00000100, B00000100, B01111000, B00000000, // h
3, 8, B01000100, B01111101, B01000000, B00000000, B00000000, // i
4, 8, B01000000, B10000000, B10000100, B01111101, B00000000, // j
4, 8, B01111111, B00010000, B00101000, B01000100, B00000000, // k
3, 8, B01000001, B01111111, B01000000, B00000000, B00000000, // l
5, 8, B01111100, B00000100, B01111100, B00000100, B01111000, // m
4, 8, B01111100, B00000100, B00000100, B01111000, B00000000, // n
4, 8, B00111000, B01000100, B01000100, B00111000, B00000000, // o
4, 8, B11111100, B00100100, B00100100, B00011000, B00000000, // p
4, 8, B00011000, B00100100, B00100100, B11111100, B00000000, // q
4, 8, B01111100, B00001000, B00000100, B00000100, B00000000, // r
4, 8, B01001000, B01010100, B01010100, B00100100, B00000000, // s
3, 8, B00000100, B00111111, B01000100, B00000000, B00000000, // t
4, 8, B00111100, B01000000, B01000000, B01111100, B00000000, // u
5, 8, B00011100, B00100000, B01000000, B00100000, B00011100, // v
5, 8, B00111100, B01000000, B00111100, B01000000, B00111100, // w
5, 8, B01000100, B00101000, B00010000, B00101000, B01000100, // x
4, 8, B10011100, B10100000, B10100000, B01111100, B00000000, // y
3, 8, B01100100, B01010100, B01001100, B00000000, B00000000, // z
3, 8, B00001000, B00110110, B01000001, B00000000, B00000000, // {
1, 8, B01111111, B00000000, B00000000, B00000000, B00000000, // |
3, 8, B01000001, B00110110, B00001000, B00000000, B00000000, // }
4, 8, B00001000, B00000100, B00001000, B00000100, B00000000 // ~
};
#define string1length 20
char string1[string1length];
//char string1[10];
//byte aamatrix[640];//4*8*100/5
byte aamatrix[32], oldaa[32];//dc*8
#define turn 2 //0..3: if turn=1 flip matrix 90 degrees cw, 2=180degrees, 3=270degrees
#define invert 0 //0=no invert, 1=invert leds
//#define orient 0 //0..2: orientation of text, left, right and middle
String sg;
int len_g;
long lo = 1000000;
int i, d2, c = 0, inpin = 2, g = 0, hi = 0, outpin = 8;
byte a;
long t = 0;
unsigned long tme, otme;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
Serial.println("Arduino Neon Geigercounter V1.0");
//Serial.end();
// initialize digital pin LED_BUILTIN as an output.
pinMode(inpin, INPUT);
pinMode(outpin, OUTPUT);
c = 0; //counter=0
d2 = 0; //high/low transition
for (int i = 0; i <= dc; i++) {
//The MAX72XX is in power-saving mode on startup, we have to do a wakeup call
lc.shutdown(i, false);
//Set the brightness to a medium values (0~15 possible values)
lc.setIntensity(i, 2);
//and clear the display
lc.clearDisplay(i);
}
randomSeed(analogRead(0));
fill_aamatrix();
tme = micros(); otme = tme;
}
void loop() {
// put your main code here, to run repeatedly:
i = digitalRead(inpin);
if (i == HIGH) d2 = 1;
if ((i == LOW) && (d2 == 1)) {
d2 = 0;
c++;
}
tme = micros();
if (tme > otme + 1000000) { //one second
otme = tme;
t = c;
update_matrix();
g = (g + c) / 2;
if (c < lo) lo = c;
if (c > hi) hi = c;
//Serial.print('/r');
//for (int t = 0; t < 10; t++) Serial.print(char(8));
Serial.print("count = ");
Serial.print(c);
Serial.print(" lo = ");
Serial.print(lo);
Serial.print(" hi = ");
Serial.println(hi);
//Serial.print(" : gemiddelde = ");
//Serial.println(g);
//Serial.print(" i = ");
//Serial.println(i);
//Serial.print(char(2));
c = 0;
}
}
void update_matrix() {
fill_oldaa();
fill_string1(t);
fill_aamatrix();
//Serial.println(t);
//delay(10);
//t += 1;
/*
for (int i = 0; i < 5*sizeof(string1); i++) {
if (turn==0) lc.setColumn(1, 4-i, aamatrix[i]);
if (turn==1) lc.setRow(1, 4-i, flip(aamatrix[i]));
if (turn==2) lc.setColumn(1, i, flip(aamatrix[i]));
if (turn==3) lc.setRow(1, 4-i, aamatrix[i]);
}*/
for (byte i = 0; i < (dc * 8); i++) {
if (oldaa[i] != aamatrix[i]) {//only update changes to matrix led's
a = dc - 1 - (i / 8);
if (turn == 0) lc.setColumn(dc - a - 1, 7 - (i % 8) , (aamatrix[i]));
if (turn == 1) lc.setRow(dc - a - 1, (i % 8) , (aamatrix[i]));
if (turn == 2) lc.setColumn(a, (i % 8) , flip(aamatrix[i]));
if (turn == 3) lc.setRow(a, 7 - (i % 8) , flip(aamatrix[i]));
}
}
}
byte d;
byte flip(byte b) {
d = ((b & B00000001) << 7);
d = d + ((b & B00000010) << 5);
d = d + ((b & B00000100) << 3);
d = d + ((b & B00001000) << 1);
d = d + ((b & B00010000) >> 1);
d = d + ((b & B00100000) >> 3);
d = d + ((b & B01000000) >> 5);
d = d + ((b & B10000000) >> 7);
if (invert == 1) d = d ^ B11111111;
return d;
}
void fill_string1(long t) {
sg = String(t) + " ";
/*
String stringOne = "Content-Type: text/html";
// you can also look for a substring in the middle of a string:
if (stringOne.substring(14,18) == "text") {
} */
//g.toCharArray(string1, sizeof(g)) ;
sg.toCharArray(string1, string1length) ;
//string1=g;
/*
for (int i = 0; i < sizeof(g); i++) {
string1[i]=g[i];
}*/
}
void clearmatrix() {
lc.clearDisplay(0);
lc.clearDisplay(1);
lc.clearDisplay(2);
lc.clearDisplay(3);
}
float f = dc * 8.0 / 5.0;;
void fill_aamatrix() {
//f=dc * 8.0 / 5.0;
//for (int v = 0; v < sizeof(string1); v++) {
for (byte v = 0; v < f; v++) {
for (byte i = 0; i < 5; i++) {
aamatrix[v * 5 + i] = CH[7 * (string1[v] - 32) + 2 + i];
}
}
}
void fill_oldaa() {
for (byte i = 0; i < 32; i++) {
oldaa[i] = aamatrix[i];
}
}