[sdiy] Pseudo random noise circuits?

Olivier Gillet ol.gillet at gmail.com
Fri Sep 17 21:27:31 CEST 2010


Outputs white noise from a 32-bits Galois LSFR, as a PWM signal on pin
11 of your Arduino:

#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>

uint32_t state = 42;

void setup() {
 pinMode(11, OUTPUT);
 TCCR2A = _BV(COM2A1) | _BV(WGM20);
 TCCR2B = _BV(CS20);
 TIMSK2 = _BV(TOIE2);
}

void loop() { }

SIGNAL(TIMER2_OVF_vect)
{
  state = (state >> 1) ^ (-(state & 1) & 0xd0000001);
  OCR2A = state & 0xff;
}



More information about the Synth-diy mailing list