1. Simulating with Wokwi

For this week, I plan to simulate controlling a LCD display with the Raspberry Pi Pico. To tie it with my final project of jamming with neuronal spiking signals, I created a module for generating random spikes and displaying the spike train on a LCD screen. The basic code to achieve this is a following, written with a little help from Wokwi demo by Urish & ChatGPT 4o mini:

#include <LiquidCrystal.h>

// Initialize the LCD with the appropriate pins
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);

// Array to hold the characters displayed on the LCD
char displayChars[16] = {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '};

// Firing Probability
float frProb=1.0/2.5;

void setup() {
  Serial.begin(9600);
  lcd.begin(16, 2); // Set up the LCD's number of columns and rows
  randomSeed(analogRead(0)); // Initialize random seed
  lcd.clear(); // Clear the display at the start
  lcd.setCursor(1,0);
  lcd.print("Random Spikes");
  //Serial.print(frProb);
  //Serial.print(ceil(1/frProb));
}

void loop() {
  // Shift all characters to the left
  for (int i = 0; i < 15; i++) {
    displayChars[i] = displayChars[i + 1];
  }

  // Randomly decide whether to display "|" at the rightmost position
  if (random(0, ceil(1/frProb)) == 1) {
    displayChars[15] = '|'; 
  } else {
    displayChars[15] = ' '; 
  }

  // Display the updated characters on the second line
  lcd.setCursor(0, 1); 
  lcd.print(displayChars);

  // Wait for a short period before the next iteration
  delay(100); // Adjust delay as needed
}

The connected LCD screen during spike generation looks like this:

Simulation Result

Simulation Result

WokWi Simulation(Not Working)