apply_stimulation | ||
dataset | ||
.gitignore | ||
build.ps1 | ||
decode_serial_digit.py | ||
gen_stimulat.py | ||
list_all_nines.py | ||
Makefile | ||
README.md | ||
stimulation_pattern.h | ||
visualize_digit.py |
Arduino CLI Installation Instructions
Windows
To install Arduino CLI on Windows using Scoop:
scoop install arduino-cli
Linux
To install Arduino CLI on Linux:
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | sh
Usage
Using Make (Linux and Windows with Make installed)
We've provided a Makefile to simplify the process of compiling and uploading sketches to your Arduino board. Here's how to use it:
-
Generate the stimulation pattern, compile, and upload the sketch:
make all
-
Only generate the stimulation pattern:
make generate
-
Only compile the sketch:
make compile
-
Only upload the compiled sketch:
make upload
-
Clean the build files and generated pattern:
make clean
You can specify a different port or board by using the PORT and BOARD variables:
make upload PORT=COM3 BOARD=arduino:avr:uno
The default board is set to Arduino Nano with old bootloader (atmega328old). To see all available options, run:
make help
Using PowerShell Script (Windows without Make)
For Windows users who don't have Make installed, we've provided a PowerShell script (build.ps1) that mimics the Makefile functionality. Here's how to use it:
-
Generate the stimulation pattern, compile, and upload the sketch:
.\build.ps1 all
-
Only generate the stimulation pattern:
.\build.ps1 generate
-
Only compile the sketch:
.\build.ps1 compile
-
Only upload the compiled sketch:
.\build.ps1 upload
-
Clean the build files and generated pattern:
.\build.ps1 clean
You can specify a different port or board by using the -PORT and -BOARD parameters:
.\build.ps1 upload -PORT COM3 -BOARD arduino:avr:uno
To see all available options, run:
.\build.ps1 help
Manual Arduino CLI Usage
If you prefer to use Arduino CLI directly, you can still use the following commands:
arduino-cli compile --fqbn arduino:avr:nano:cpu=atmega328old your_sketch.ino
arduino-cli upload -p COMx --fqbn arduino:avr:nano:cpu=atmega328old your_sketch.ino
Replace COMx
with the appropriate port for your Arduino board (e.g., COM20).
Project Goal
The goal of this project is to create a system that generates and applies stimulation patterns based on MNIST handwritten digits to a special sample of nano fibers. These nano fibers act as a reservoir, essentially functioning as a small "mind" or computing system. This setup aims to explore the potential of reservoir computing using nano fibers for pattern recognition and information processing.
The project workflow is as follows:
- Generate a stimulation pattern from MNIST data (gen_stimulat.py)
- Upload this pattern to an Arduino board (using Arduino CLI, Makefile, or PowerShell script)
- The Arduino applies the stimulation pattern to the nano fiber sample (apply_stimulation.ino)
- Receive and decode the response data from the nano fiber reservoir (decode_serial_digit.py)
- Visualize the received data to interpret the reservoir's response (visualize_digit.py)
This setup allows for experimenting with how nano fiber reservoirs can process and potentially recognize complex patterns like handwritten digits, exploring the intersection of materials science and neuromorphic computing.
Python Scripts
This project includes several Python scripts for working with MNIST digit data and Arduino communication. Here's a brief overview of each script:
decode_serial_digit.py
This script reads data from a serial port (default: COM20), expecting to receive response values from the nano fiber reservoir after stimulation. It then plots the received data using matplotlib.
Usage:
python decode_serial_digit.py
gen_stimulat.py
This script generates a stimulation pattern from the MNIST dataset. It reads the training images and labels, selects the first occurrence of the digit '9', and converts its pixel values to a stimulation pattern. The pattern is then written to a C header file (stimulation_pattern.h) for use with Arduino.
Usage:
python gen_stimulat.py
list_all_nines.py
This script reads the MNIST training labels and identifies all occurrences of the digit '9'. It prints the total count of '9's in the training set and the first 10 indices where '9' appears.
Usage:
python list_all_nines.py
visualize_digit.py
This script provides a function to visualize a digit pattern using ASCII characters. It can be used to visualize both input stimulation patterns and the reservoir's response.
Usage:
python visualize_digit.py
These scripts work together to process MNIST data, generate stimulation patterns, and visualize the results of the nano fiber reservoir's computations. They are designed to be used in conjunction with the Arduino sketch for controlling the stimulation of the nano fiber sample.