Visual hallucinations induced with two blinking LEDs - Page 1
Forum section: electronics / projects

author: RoGeorge
author_rank: Super Contributor
timestamp: September 07, 2022, 07:06:13 am
content: Disclaimer, the following circuit has blinking lights:Do not try any of these if prone to epileptic seizures and alike.Whatever you'll do, will be on your own responsibility entirely.Many, many, many moons ago, did once a funny kind of LED blinker called "Brain Machine"!The project by Mitch Altman was all the rage back then, and it really works, makes one see colors other than the LEDs' color, and other complex visual patterns. The circuit also produces a stereo sound (apart from the DOs dedicated to blink the two LEDs), but the sound doesn't seem to have any strange effect, while the blinking lights certainly have for everybody I've tested. At some point it was published in the "Make:" magazine, too.Googled a little and, what a nice surprise, "The Brain Machine" page is still there, on the Makezine website:https://makezine.com/projects/the-brain-machine/My implementation was with a different MCU, an ATtiny25, because that's what it happened to have at hand, but I've kept the same timings and waveforms for both the blinks and the audio. Found the code that I've used with the ATiny25. IIRC, I've started from a code published on Adafruit, and adapted that for my setup:Code:/** BM1.c** Created: 2012.04.06 07:14:21**//*#include <avr/io.h>int main(void){while(1){//TODO:: Please write your application code}}*//*Brain MachineFirmwarefor use with ATtiny2525-Oct-07*/#include <avr/io.h> // this contains all the IO port definitions#include <avr/interrupt.h> // definitions for interrupts#include <avr/sleep.h> // definitions for power-down modes#include <avr/pgmspace.h> // definitions or keeping constants in program memory/*The hardware for this project is very simple:Disclaimer:Do not try any of that if prone to epileptic seizures and alike.Beware that everything you do is entirely your responsibility.ATtiny25 has 8 pins:pin 1 no connectionpin 2 PB3 - Left eye LED1 -- through a 47 ohm resistorpin 3 no connectionpin 4 groundpin 5 OC0A - Left ear speaker (base-frequency) -- through an LPF of 2.2K and 1uF bipolarpin 6 OC1A - Right ear speaker (Offset Frequencies for binaural beats) -- through an LPF of 2.2K and 1uF bipolarpin 7 PB2 - Right eye LED2 -- through a 47 ohm resistorpin 8 +3v (CR2032 through a switch)All other pins are unusedThis firmware requires that the clock frequency of the ATtinyis the default that it is shipped with: 8.0MHz internal oscillator*//*The C compiler creates code that will transfer all constants into RAM when the microcontrollerresets. Since this firmware has a table (brainwaveTab) that is too large to transfer into RAM,the C compiler needs to be told to keep it in program memory space. This is accomplished bythe macro PROGMEM (this is used, below, in the definition for the brainwaveTab). Since theC compiler assumes that constants are in RAM, rather than in program memory, when accessingthe brainwaveTab, we need to use the pgm_read_byte() and pgm_read_dword() macros, and we needto use the brainwveTab as an address, i.e., precede it with "&". For example, to accessbrainwaveTab.bwType, which is a byte, this is how to do it:pgm_read_byte( &brainwaveTab.bwType );And to access brainwaveTab.bwDuration, which is a double-word, this is how to do it:pgm_read_dword( &brainwaveTab.bwDuration );*/// table of values for meditation// start with lots of Beta (awake / conscious)// add Alpha (dreamy / trancy to connect with subconscious Theta that'll be coming up)// reduce Beta (less conscious)// start adding Theta (more subconscious)// pulse in some Delta (creativity)// and then reverse the above to come up refreshedstruct brainwaveElement {char bwType; // 'a' for Alpha, 'b' for Beta, 't' for Theta, or 'd' for Delta ('0' signifies last entry in tableunsigned long int bwDuration; // Duration of this Brainwave Type (divide by 10,000 to get seconds)} const brainwaveTab[] PROGMEM = {{ 'b', 600000 },{ 'a', 100000 },{ 'b', 200000 },{ 'a', 150000 },{ 'b', 150000 },{ 'a', 200000 },{ 'b', 100000 },{ 'a', 300000 },{ 'b', 50000 },{ 'a', 600000 },{ 't', 100000 },{ 'a', 300000 },{ 't', 200000 },{ 'a', 300000 },{ 't', 300000 },{ 'a', 150000 },{ 't', 600000 },{ 'a', 150000 },{ 'b', 10000 },{ 'a', 150000 },{ 't', 600000 },{ 'd', 10000 },{ 't', 100000 },{ 'd', 10000 },{ 't', 100000 },{ 'd', 10000 },{ 't', 300000 },{ 'a', 150000 },{ 'b', 10000 },{ 'a', 150000 },{ 't', 300000 },{ 'a', 150000 },{ 'b', 10000 },{ 'a', 200000 },{ 'b', 50000 },{ 'a', 200000 },{ 'b', 150000 },{ 'a', 150000 },{ 'b', 200000 },{ 'a', 100000 },{ 'b', 250000 },{ 'a', 50000 },{ 'b', 600000 },{ '0', 0 }};// This function delays the specified number of 1/10 millisecondsvoid delay_one_tenth_ms(unsigned long int ms) {unsigned long int timer;const unsigned long int DelayCount=87; // this value was determined by trial and errorwhile (ms != 0) {// Toggling PB5 is done here to force the compiler to do this loop, rather than optimize it awayfor (timer=0; timer <= DelayCount; timer++) {PINB |= 0b0100000;};ms--;}}// This function blinks the LEDs (connected to PB3, PB2 - for Left eye, Right eye, respectively)// at the rate determined by onTime and offTime// and keeps them blinking for the Duration specified (Duration given in 1/10 millisecs)// This function also acts as a delay for the Duration specifiedvoid blink_LEDs( unsigned long int duration, unsigned long int onTime, unsigned long int offTime) {for (int i=0; i<(duration/(onTime+offTime)); i++) {PORTB |= 0b00001100; // turn on LEDs at PB3, PB2delay_one_tenth_ms(onTime); // for onTimePORTB &= 0b11110011; // turn off LEDs at PB3, PB2delay_one_tenth_ms(offTime); // for offTime}}// This function starts the Offset Frequency audio in the Right ear through output OC1A (using Timer 1)// to create a binaural beat (between Left and Right ears) for a Brainwave Element// (the base-frequency of 200.321Hz is already assumed to be playing in the Left ear before calling this function)// and blinks the LEDs at the same frequency for the Brainwave Element// and keeps it going for the Duration specified for the Brainwave Element// The timing for the Right ear is done with 8-bit Timer 1 (set up for CTC Mode, toggling output on each compare)// Output frequency = Fclk / (2 * Prescale * (1 + OCR1C) ) = 8,000,000 / (2 * (1 + OCR1C) )void do_brainwave_element(int index) {char brainChr = pgm_read_byte(&brainwaveTab.bwType);if (brainChr == 'b') {// Beta// start Timer1 with the correct Offset Frequency for a binaural beat for the Brainwave Type// to Right ear speaker through output OC1A (PB1, pin 6)OCR1C = 71; // T1 generates 217.014Hz, for a binaural beat of 16.7Hz// delay for the time specified in the table while blinking the LEDs at the correct rate// onTime = 30.0ms, offTime = 29.9ms --> 16.7Hzblink_LEDs( pgm_read_dword(&brainwaveTab.bwDuration), 300, 299 );return; // Beta}else if (brainChr == 'a') {// Alpha// start Timer1 with the correct Offset Frequency for a binaural beat for the Brainwave Type// to Right ear speaker through output OC1A (PB1, pin 6)OCR1C = 73; // T1 generates 211.149Hz, for a binaural beat of 10.8Hz// delay for the time specified in the table while blinking the LEDs at the correct rate// onTime = 46.2ms, offTime = 46.2ms --> 10.8Hzblink_LEDs( pgm_read_dword(&brainwaveTab.bwDuration), 462, 462 );return; // Alpha}else if (brainChr == 't') {// PORTB &= 0b00001100; // (for debugging purposes only -- commented out for SLM)// PORTB |= 0b00100000;// Theta// start Timer1 with the correct Offset Frequency for a binaural beat for the Brainwave Type// to Right ear speaker through output OC1A (PB1, pin 6)OCR1C = 75; // T1 generates 205.592Hz, for a binaural beat of 5.3Hz// delay for the time specified in the table while blinking the LEDs at the correct rate// onTime = 94.8ms, offTime = 94.9ms --> 5.3Hzblink_LEDs( pgm_read_dword(&brainwaveTab.bwDuration), 948, 949 );return; // Theta}else if (brainChr == 'd') {// PORTB &= 0b00001100; // (for debugging purposes only -- commented out for SLM)// PORTB |= 0b00010000;// Delta// start Timer1 with the correct Offset Frequency for a binaural beat for the Brainwave Type// to Right ear speaker through output OC1A (PB1, pin 6)OCR1C = 76; // T1 generates 202.521Hz, for a binaural beat of 2.6Hz// delay for the time specified in the table while blinking the LEDs at the correct rate// onTime = 1922ms, offTime = 1923ms --> 2.6Hzblink_LEDs( pgm_read_dword(&brainwaveTab.bwDuration), 1922, 1923 );return; // Delta}// this should never be executed, since we catch the end of table in the main loopelse {// PORTB &= 0b00001100; // (for debugging purposes only -- commented out for SLM)// PORTB |= 0b00000010;return; // end of table}}static volatile unsigned int power __attribute__ ((section (".noinit")));int main(void) {if (power == 0) {power = 1;// Shut down everything and put the CPU to sleepTCCR0B &= 0b11111000; // CS02:CS00=000 to stop Timer0 (turn off audio in Right ear speaker)TCCR1 &= 0b11110000; // CS13:CS10=0000 to stop Timer1 (turn off audio in Left ear speaker)MCUCR |= 0b00100000; // SE=1 (bit 5)MCUCR |= 0b00010000; // SM1:0=10 to enable Power Down Sleep Mode (bits 4, 3)delay_one_tenth_ms(10000); // wait 1 secondPORTB = 0x00; // turn off all PORTB outputsDDRB = 0x00; // make PORTB all inputssleep_cpu(); // put CPU into Power Down Sleep Mode}power = 0;TIMSK = 0x00; // no Timer interrupts enabledDDRB = 0b00001111; // set PB0, PB1, PB2, PB2 pins as outputs (PB5 and PB4 remain inputs)PORTB = 0x00; // all PORTB output pins Off (no pull-ups on inputs pins PB5, PB4)// start up Base frequency = 200.321Hz on Left ear speaker through output OC0A (using Timer0)// 8-bit Timer0 OC0A (PB0, pin 5) is set up for CTC mode, toggling output on each compare// Fclk = Clock = 8MHz// Prescale = 256// OCR0A = 77// F = Fclk / (2 * Prescale * (1 + OCR0A) ) = 200.321HzTCCR0A = 0b01000010; // COM0A1:0=01 to toggle OC0A on Compare Match// COM0B1:0=00 to disconnect OC0B// bits 3:2 are unused// WGM01:00=10 for CTC Mode (WGM02=0 in TCCR0B)TCCR0B = 0b00000100; // FOC0A=0 (no force compare)// F0C0B=0 (no force compare)// bits 5:4 are unused// WGM2=0 for CTC Mode (WGM01:00=10 in TCCR0A)// CS02:00=100 for divide by 256 prescalerOCR0A = 77; // to output 200.321Hz on OC0A (PB0, pin 5)// set up T1 to accept Offset Frequencies on Right ear speaker through OC1A (but don't actually start the Timer1 here)// 8-bit Timer1 OC1A (PB1, pin 6) is set up for CTC mode, toggling output on each compare// Fclk = Clock = 8MHz// Prescale = 256// OCR1A = value for Beta, Alpha, Theta, or Delta (i.e., 18628, 18919, 19386, or 19750)// F = Fclk / (2 * Prescale * (1 + OCR1C) )TCCR1 = 0b10011001; // CTC1=1 to reset timer1 on match with 0CR1C// PWM1A=0 for no PWM mode// COM1A1:0=01 to toggle OC1A on Compare Match// CS13:10=1001 for divide by 256 prescaler// loop through entire Brainwave Table of Brainwave Elements// each Brainwave Element consists of a Brainwave Type (Beta, Alpha, Theta, or Delta) and a Duration// Seeing the LEDs blink and hearing the binaural beats for the sequence of Brainwave Elements// synchs up the user's brain to follow the sequence (hopefully it is a useful sequence)int j = 0;while (pgm_read_byte(&brainwaveTab.bwType) != '0') { // '0' signifies end of tabledo_brainwave_element(j);j++;}// Shut down everything and put the CPU to sleepTCCR0B &= 0b11111000; // CS02:CS00=000 to stop Timer0 (turn off audio in Right ear speaker)TCCR1 &= 0b11110000; // CS13:CS10=0000 to stop Timer1 (turn off audio in Left ear speaker)MCUCR |= 0b00100000; // SE=1 (bit 5)MCUCR |= 0b00010000; // SM1:0=10 to enable Power Down Sleep Mode (bits 4, 3)delay_one_tenth_ms(10000); // wait 1 secondPORTB = 0x00; // turn off all PORTB outputsDDRB = 0x00; // make PORTB all inputssleep_cpu(); // put CPU into Power Down Sleep Mode}Would be nice to port that for Arduino, so to be easy to test by anybody who have an Arduino and 2 LEDs.Searched online, and the Adafruit page and the github repository are still available:https://learn.adafruit.com/brain-machinehttps://github.com/adafruit/Adafruit_Brain-Machine-KitSearched offline, and found my breadboard with ATtiny25:My interpretation back then was that the pulses were producing some sort of a Heaviside steps, and that was rich in many other frequencies than the usual (in comparison with the normal nervous activity rhythms), so the pulses were ringing in the nervous paths giving birth to colors and patterns.Would like to test the hypotheses by using pulses with soft edges instead, like a Gaussian with the same energy as the square pulse (because the Fourier of a Gaussian is also a Gaussian shape, so no harmonics). I would expect for the colors and patterns illusions to not form when the LEDs are blinking with Gaussian pulses instead of square pulses.What I'm curious about is if the patterns and colors will still be seen if, instead of square pulses and sudden pattern changes, the LEDs will be driven by a Gaussian shape waveform.Any help, suggestions or collaboration is welcome and highly appreciated.Same if you are willing to build your own, then test and share the results.

author: Alex Eisenhut
author_rank: Super Contributor
timestamp: September 08, 2022, 03:01:08 am
content: That's a 1980s Radio-Electronics project?

author: floobydust
author_rank: Super Contributor
timestamp: September 08, 2022, 03:50:34 am
content: OP- how unoriginal (edit: the Mitch Altman project). It might have been "Alpha/Theta Meditation Goggles" Radio Electronics Apr. 1989, letters May, Oct. I don't see it on the Web. I have a paper copy somewhere.I'd built it back then, an era where blue LED's were only SiC and expensive. Basically a trio of LED's arranged as RGB and maybe a 4017 to control the fade in and out. I don't think it was in Popular Electronics.There are other light stimulations that have effects on the brain. I did some work with war vets suffering PTSD. It does have real use, as opposed to toy effects.

author: RoGeorge
author_rank: Super Contributor
timestamp: September 08, 2022, 06:39:16 am
content: Quote from: Alex Eisenhut on September 08, 2022, 03:01:08 amI don't know when or where did from the idea originated. From the piece of code I've accidentally found in one of my directories, I've tried the blinker in 2012.There are tales about tribes using something similar (blinking light) to get into some sort of trance state by looking at the sun with the eyes shut, then waiving the fingers in front of the eyes to produce on/off like blinking of the sunlight.Other testimonies are from people traveling eyes shut along a road with trees on the side, and getting visual effects from the blinking shadows casted by the trees.It certainly precedes LEDs, there are written instructions of how to build a similar machine by putting a lightbulb inside of a transparent cylinder with black patches on it, then turning the cylinder (i.e. with a 78 RPM turntable - Brion Gysin) to generate on/off patterns of light. Something like this:https://en.wikipedia.org/wiki/DreamachineImage source:http://artistsbooksandmultiples.blogspot.com/2016/02/brion-gysin-dream-machine.htmlAn image search will show other similar patterns, probably before the time when LEDs became ubiquitous:https://duckduckgo.com/?q=dreamachine+cylinder&iar=imagesQuote from: floobydust on September 08, 2022, 03:50:34 amThank for the reference, was it this (at page 47 of 100):https://worldradiohistory.com/Archive-Radio-Electronics/80s/1989/Radio-Electronics-1989-04.pdf?Quote from: floobydust on September 08, 2022, 03:50:34 amVery interesting. Does it happen for you to ever test softer light-transitions in the PTSD research, either softer on/off blinking edges, or softer changes between two frequencies (instead of a frequency jump)?Asking because it just happen that some other thread (https://www.eevblog.com/forum/beginners/led-backlighting-suggestions-(4-in-cc-config-3-2-3-4v-20ma)/msg4401754/#msg4401754) reminded me about this forgotten circuit, and how I never tested soft variations in frequency and/or on/off edges of light. Then made this thread in the hope others will be willing to experiment if the code will be ported to Arduino (plenty of people have an Arduino and 2 LEDs).Thus, the purpose of this thread to me is to test together with others the hypotheses about softer transitions (particularly with a Gaussian shape).This is what i would like to test:Quote from: RoGeorge on September 07, 2022, 07:06:13 amSo, does it happen for you to have/know any results about using pulses with softer edges and/or softer frequency transitions?

author: Mechatrommer
author_rank: Super Contributor
timestamp: September 08, 2022, 07:15:22 am
content: if you lazy, there one ready made for you just using your monitor...skip to the ending part if you dont want induction session, and if you dont see the effect the first try, try different variant, look away, look at the center, close your eyes in dark room or wave your hand. and if you still dont see the effect, then you'll know this kind of stuffs is just placebo. if you got pissed, google sci fi short film "Headcleaner" and do it in a dark room, but you need to have the balls, you've been warned i'm not responsible. it can get into your nerve as well.otoh one cause of hallucination is simply "sensory deprivation"... so you can pretty much give any kind of stimulation to make it happenshttps://www.britannica.com/science/hallucination/Sensory-deprivation

author: RoGeorge
author_rank: Super Contributor
timestamp: September 08, 2022, 09:08:44 am
content: He, he, the blinker in the OP won't give the kind of visual hallucinations shown in the middle of that fiction movie. Also, I didn't experienced any effects with the violent flashes shown at the end of the video. Never experienced any epilepsy-like episodes, but I know other people can be very sensitive to flashing lights.The LED blinker circuit gives very reproducible and consistent results even for me (someone not prone to light induced epilepsy). Though the induced effects from the LED blinker were not "movies like" hallucinations. I could only see colors (that weren't there in reality), and repeating patterns.About the sensory deprivation hallucinations, I have a pet theory of mine about what conscience is, and that fits well as an explanation for sensory deprivation induced hallucinations. The main idea (in little words) is like I already wrote in another post, so I'll just copy it again here:Quote from: RoGeorge on August 21, 2022, 07:37:12 amI considerthe non-stop simulationthat happens inside the neural-networks of our own brainas our consciousness, the stream of thoughts and the self-awareness that makes us think we are conscious sentient beings.In normal situations, the simulation that happens in our brain is continuously guided by our senses. There is a closed control loop, in which the output (the simulation) is compared with the input (sensory streams - hearing, seeing, vestibular, etc.) and the simulation is adjusted to minimize the errors, to minimize the discrepancies between the predicted simulation and the measured reality.When the data stream from our senses is cut (for example by sensory deprivation, as you mentioned, or during sleep time) then the only input driving the simulation is mostly noise, and thus the hallucinations caused by sensory depredation, or the bizarre word of dreams.Dreams (in the spirit of this theory) are also simulations produced by our brain, just like our consciousness is, except that dreams are driven mostly by noise input, instead of being driven by sensory inputs coming from the real world.A blinking screen, that's a very good idea to take away! A screen is way more accessible than an Arduino and 2 LEDs. Maybe that's the way to go with the experiments, by preparing short videos to be played on a screen split in half, one half for each eye, instead of Arduino programs. The screen could be a monitor as well as a mobile phone or a tablet.

author: Terry Bites
author_rank: Super Contributor
timestamp: September 08, 2022, 10:50:46 am
content: I'm not sure whether I'll have a migraine or a siezure.

author: Mechatrommer
author_rank: Super Contributor
timestamp: September 08, 2022, 11:02:33 am
content: Quote from: RoGeorge on September 08, 2022, 09:08:44 amit is a "prediction" process at subconcious level from learned experiences, risk management also comes to play and differ between individuals. thats what is tried to be emulated in AI. but when prediction is wrong, before new experience is learned, we tipped, fall off the stair, smash or overturn a car etc, much more happened to younger kids. this explained why older people behaves differently from younger people, due to learned experiences. but i consider this as basic stuffs that we almost understand about it...Quote from: RoGeorge on September 08, 2022, 09:08:44 amsimply creating a non-stop "prediction" or "simulation" wont simply make a creation concious. consciousness is the higher level of thought process through meta cognition. that is less or partly understood. the ultimatum of that is the question such as why am i here? what is my purpose? who created me and how do i get created? creativity or innovation could be emulated in AI, but i'm not sure about meta cognition in its entirety.Quote from: RoGeorge on September 08, 2022, 09:08:44 ampartly true imho. but there are things such as premonitions (during awake), previsions in dreams etc that actually come true, happened to some people (usually believers), happened to me when i was very little and i still remember it. afawk is a non-causal process. thats why we believe there are higher dimension creations/awareness that can channel informations not through observable physical medium, sometime not even bound by time. supernatural things are another things, we are not alone, we dont see them doesnt mean they are not there, we dont even fully understand whats our constituents from, and what we are fully capable of. thats why our "book" makes much more sense in this regards