Mirko Pavleski
Published © GPL3+

Arduino Cranial Stimulator (Bio-BrainTuner)

Cranial electro stimulation uses harmonic frequencies to help balance the brain's chemistry.

IntermediateFull instructions provided3,623
Arduino Cranial Stimulator (Bio-BrainTuner)

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
2N3904 transistor
×2
2N3906 transistor
×1
1N4007 – High Voltage, High Current Rated Diode
1N4007 – High Voltage, High Current Rated Diode
×4
Rotary potentiometer (generic)
Rotary potentiometer (generic)
×2
LED (generic)
LED (generic)
×2
Pushbutton Switch, Momentary
Pushbutton Switch, Momentary
×1
Slide Switch
Slide Switch
×1
Output Audio trafo from old MW radio
×1
resistors and capacitors
×1

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free

Story

Read more

Schematics

Shematic timer

Schematic simple

Code

Arduino code

Arduino
// @TESLATRONICA 2019.

// pin 9 arduino nano >>> out signal 111 Hz
// pin 3 arduino nano >>> out signal 1110 Hz

//pin A0 arduino nano >>> to cental pin pontentiometer 10k (for gate regulation)
// right pin potentiometer 10k to +5V
// left pin potentiometer 10k to negative
// potentiometer all left >>> no gate (constant output signal)
// potentiometer move to right >>> activate gate 5 Hz to 0.5 Hz (200 ms to 2s aprox)

long time_;

int gate_ = 0;
long gate_contador = 0;
int gate5 = 0;
int gate_2 = 0;

int array_time_gate[] = {0, 200, 500, 1000, 1500, 2000}; // gate values 5 Hz to 0.5 Hz (200 ms to 2s aprox)
int startButton = 13; //pin recieving info from start button
int startLED = 4;   
unsigned long timerCount = 0; // variable to hold our timer info
#include <PWM.h> // library frequency "PWM"

void setup() {
  pinMode(startButton, INPUT_PULLUP); //set pin as recieving info
  pinMode(startLED, OUTPUT); 
  digitalWrite(startLED, LOW); 
  
   InitTimersSafe();

  SetPinFrequencySafe(9, 111); // 111 Hz to pin PWM 9
  pwmWrite(9, 50 * 2.55); // 50% duty Cicle

  SetPinFrequencySafe(3, 1110); // 1110 Hz to pin PWM 3
  pwmWrite(3, 50 * 2.55); // 50% duty Cicle
}

void loop() {
if (digitalRead(startButton) == HIGH) 
    { //if the start button has be pushed
     timerCount = 20 * 60 * 10; //set timer to approximately 5 mins 
     //(20 mins *  60 sec * 10 * 1 deciseconds)
     //this is set up to restart the timer whenever the start 
     //button is pushed
     //not extremely exact since that is not what I needed for this project
     //if you are looking for something more exact, look into 
     //SimpleTimer() Arduino funtions and libraries:
     //http://playground.arduino.cc/Code/SimpleTimer#F_restartTimer
    }
  if (timerCount != 0)
   { //if the count down timer is still running
     digitalWrite(startLED, HIGH); 
     //tell the control pin to provide power to the project
     timerCount = timerCount - 1; 
     //count down of a decisecond (0.1 sec)
     delay(100); 
     //delay for timercCount refrence of a decisecond
   } 
   else { //if the timer has run out
     digitalWrite(startLED, LOW);
   }
  
  time_ = millis(); // read time since arduino power on

  gate_ = analogRead (0); // read pin A0 values of the "arduino nano" seleccionated with potentiometer 10K
  gate_ = map(gate_, 0, 1023, 0, 6); // 0 to 6 >>> 5 Hz to 0.5 Hz (200 ms to 2s aprox)
  if (gate_ > 5) {
    gate_ = 5;
  }
  gate_ = array_time_gate[gate_]; // read array fron potentiometer

  if (gate_ != 0) { //active gate
    gate(); // call to gate subroutine
  }

  if (gate_ == 0 && gate_2 == 1) { //reactivate frequencies
    SetPinFrequencySafe(9, 111); // 111 Hz to pin PWM 9
    pwmWrite(9, 50 * 2.55); // 50% duty Cicle

    SetPinFrequencySafe(3, 1110); // 1110 Hz to pin PWM 3
    pwmWrite(3, 50 * 2.55); // 50% duty Cicle
    gate_2 = 0;
  }
}


void gate() { // gate subroutine
  if (gate_ > gate5 + 2 || gate_ < gate5 - 2) {
    gate_contador = millis();
    gate5 = gate_;
    gate_2 = 1;
  }

  if (gate_2 == 0 && time_ >= gate_contador) { // desactivate pin9 and pin3
    pwmWrite(9, 0);
    pwmWrite(3, 0);
    gate_contador = gate_ + millis(); // selected gate valued + current time
    gate_2 = 1;
  }

  if (gate_2 == 1 && time_ >= gate_contador) { // active pin9 and pin3
    pwmWrite(9, 50 * 2.55);
    pwmWrite(3, 50 * 2.55);
    gate_contador = gate_ + millis(); // selected gate value + current time
    gate_2 = 0;
  }
}

Credits

Mirko Pavleski

Mirko Pavleski

149 projects • 1282 followers

Comments