Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
Arnov Sharma
Published © MIT

PICO Sequencer

PICO Sequencer is a DIY version of the famous Pocket Operator Synth Sequencer Devices.

BeginnerFull instructions provided1 hour862
PICO Sequencer

Things used in this project

Hardware components

Raspberry Pi Pico 2
Raspberry Pi Pico 2
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Seeed Studio Fusion PCB/PCBA
Seeed Studio Fusion PCB/PCBA

Story

Read more

Schematics

SCH

Code

code

C/C++
#include <Wire.h>

// Define keypad pins
const int rows = 5;
const int cols = 5;
const int rowPins[rows] = {16, 17, 18, 19, 20}; // Updated row pins
const int colPins[cols] = {6, 7, 8, 9, 10}; // Updated col pins

// Define frequencies for buttons
const int frequencies[5][3] = {
  {110, 123, 146}, // Row 1
  {164, 196, 220}, // Row 2
  {246, 294, 330}, // Row 3
  {349, 392, 440}, // Row 4
  {494, 523, 587}  // Row 5 (last button will be for record)
};

// Pin for speaker
const int speakerPin = 21;

// Recording variables
bool isRecording = false;
unsigned long sequence[100];
int sequenceIndex = 0;

// Button coordinates
const int recordRow = 4;
const int recordCol = 2; // Last button in Row 5
const int delayRow = 4;
const int delayCol = 1; // Second to last button in Row 5

void setup() {
  Serial.begin(115200);

  // Initialize row pins as inputs
  for (int i = 0; i < rows; i++) {
    pinMode(rowPins[i], INPUT_PULLUP);
  }

  // Initialize column pins as outputs
  for (int i = 0; i < cols; i++) {
    pinMode(colPins[i], OUTPUT);
    digitalWrite(colPins[i], HIGH);
  }

  // Initialize speaker pin as output
  pinMode(speakerPin, OUTPUT);
  Serial.println("Setup complete.");
}

void playSound(int freq) {
  tone(speakerPin, freq, 200); // Play sound on pin 21 for 200ms
  Serial.print("Playing sound at frequency: ");
  Serial.println(freq);
}

void playSequence() {
  for (int i = 0; i < sequenceIndex; i++) {
    playSound(sequence[i]);
    if (digitalRead(rowPins[delayRow]) == LOW && digitalRead(colPins[delayCol]) == LOW) {
      delay(750); // Add delay if delay button is pressed (adjust as needed)
    } else {
      delay(250); // Default delay between notes in the sequence
    }
  }
}

void loop() {
  for (int i = 0; i < cols; i++) {
    digitalWrite(colPins[i], LOW); // Activate column i
    for (int j = 0; j < rows; j++) {
      if (digitalRead(rowPins[j]) == LOW) { // Button press detected
        if (i == recordCol && j == recordRow) { // Check if it's the record button
          if (isRecording) {
            isRecording = false;
            Serial.println("Recording stopped. Playing sequence...");
            tone(speakerPin, 880, 500); // Play tone to signal recording stop
            delay(500); // Delay to avoid multiple triggers
            playSequence(); // Play recorded sequence
          } else {
            isRecording = true;
            sequenceIndex = 0;
            Serial.println("Recording started...");
            tone(speakerPin, 440, 500); // Play tone to signal recording start
            delay(500); // Delay to avoid multiple triggers
          }
        } else if (!(i == delayCol && j == delayRow)) { // First 10 buttons for tones, excluding delay button
          playSound(frequencies[j][i]);
          if (isRecording) {
            sequence[sequenceIndex] = frequencies[j][i];
            sequenceIndex++;
            Serial.print("Recording note: ");
            Serial.println(frequencies[j][i]);
          }
        }
        delay(200); // Debounce delay
      }
    }
    digitalWrite(colPins[i], HIGH); // Deactivate column i
  }
}

Credits

Arnov Sharma
320 projects • 326 followers
Just your average MAKER
Contact

Comments

Please log in or sign up to comment.