Oussama_ETTAOUILKarem BenChikha
Published

Arduino Synth

Arduino Synth is a project that consists of creating an 8-bit capacitive synthesizer.

IntermediateShowcase (no instructions)2 hours4,621
Arduino Synth

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
ATmega328
Microchip ATmega328
×1
USB-A to B Cable
USB-A to B Cable
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Arduino Synth Board On Eagle software

Code

Synthesizer.ino

Arduino
/*
  Synthesizer
  creating sound from electronics
  
  This example is part of the Fritzing Creator Kit: www.fritzing.org/creator-kit.
*/

int buzzerPin = 8;                             // piezo pin declaration
int potPin1 = 0;                               // potentiometer 1 pin declaration
int potPin2 = 1;                               // potentiometer 2 pin declaration

int toneHeight;                                // store the tone height
int lfo;                                       // store the frequency speed

/* lfo is a "low frequency oscillator" - so a frequency change depending on time */

void setup() {
  pinMode(buzzerPin, OUTPUT);                  // buzzerPin as output
}

void play(int myToneHeight) {                  // play method
    digitalWrite(buzzerPin, HIGH);             // piezo is switched on
    delayMicroseconds(myToneHeight);           // stopping time influenced by toneHeight 
    digitalWrite(buzzerPin, LOW);              // piezo is switched off
    delayMicroseconds(myToneHeight);           // stopping time influenced by toneHeight 
}

void loop() {
  toneHeight=analogRead(potPin1);              // toneheight is value of potentiometer 1
  lfo=analogRead(potPin2);                     // lfo is value of potentiometer 2
  
  for (int i = (lfo/10); i > 0; i--) {         // toneheight rising depending on lfo
    play(toneHeight);                          // execute play method
  }
  delayMicroseconds(lfo);                      // break
  for (int i = 0; i < lfo/10; i++) {           // toneheight sinking depending on lfo
    play(toneHeight);                          // execute play method
  }
}

Credits

Oussama_ETTAOUIL

Oussama_ETTAOUIL

3 projects • 1 follower
Karem BenChikha

Karem BenChikha

13 projects • 19 followers
Hi everyone 👋 I'm a robotics engineer

Comments