Arnov Sharma
Published © MIT

DIY LM317 Based Buck Converter

Made a super small Buck converter module based around LM317 that can provide a stable 5V for powering XYZ electronics.

BeginnerFull instructions provided1 hour29
DIY LM317 Based Buck Converter

Things used in this project

Hardware components

Raspberry Pi Pico 2
Raspberry Pi Pico 2
×1
NextPCB  Custom PCB Board
NextPCB Custom PCB Board
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

SCH

Code

code

C/C++
#include <Adafruit_Protomatter.h>
// Pin definitions
#define R1 2
#define G1 3
#define B1 4
#define R2 5
#define G2 8
#define B2 9
#define A 10
#define B 16
#define C 18
#define D 20
#define CLK 11
#define LAT 12
#define OE 13
#define WIDTH 64
#define HEIGHT 32
uint8_t rgbPins[] = { R1, G1, B1, R2, G2, B2 };
uint8_t addrPins[] = { A, B, C, D };
Adafruit_Protomatter matrix(WIDTH, HEIGHT, 1, rgbPins, 4, addrPins, CLK, LAT, OE, false);
bool grid[WIDTH][HEIGHT];
bool newGrid[WIDTH][HEIGHT];
void setup() {
matrix.begin();
randomSeed(analogRead(0));
// Initialize grid with random values
for(int x = 0; x < WIDTH; x++) {
for(int y = 0; y < HEIGHT; y++) {
grid[x][y] = random(2);
}
}
}
void loop() {
matrix.fillScreen(0);
// Update grid based on Game of Life rules
for(int x = 0; x < WIDTH; x++) {
for(int y = 0; y < HEIGHT; y++) {
int aliveNeighbors = countAliveNeighbors(x, y);
if(grid[x][y]) {
// Any live cell with two or three live neighbors survives.
if(aliveNeighbors < 2 || aliveNeighbors > 3) {
newGrid[x][y] = false;
} else {
newGrid[x][y] = true;
}
} else {
// Any dead cell with three live neighbors becomes a live cell.
if(aliveNeighbors == 3) {
newGrid[x][y] = true;
} else {
newGrid[x][y] = false;
}
}
if(newGrid[x][y]) {
matrix.drawPixel(x, y, matrix.color565(255, 255, 255)); // White color
}
}
}
// Copy newGrid to grid
memcpy(grid, newGrid, sizeof(grid));
matrix.show();
delay(100); // Adjust the delay for speed control
// Check if the grid is stable or empty
if(isGridStableOrEmpty()) {
resetGrid();
}
}
int countAliveNeighbors(int x, int y) {
int aliveNeighbors = 0;
for(int dx = -1; dx <= 1; dx++) {
for(int dy = -1; dy <= 1; dy++) {
if(dx == 0 && dy == 0) continue;
int nx = (x + dx + WIDTH) % WIDTH;
int ny = (y + dy + HEIGHT) % HEIGHT;
if(grid[nx][ny]) {
aliveNeighbors++;
}
}
}
return aliveNeighbors;
}
bool isGridStableOrEmpty() {
for(int x = 0; x < WIDTH; x++) {
for(int y = 0; y < HEIGHT; y++) {
if(grid[x][y]) {
return false;
}
}
}
return true;
}
void resetGrid() {
for(int x = 0; x < WIDTH; x++) {
for(int y = 0; y < HEIGHT; y++) {
grid[x][y] = random(2);
}
}
}

Credits

Arnov Sharma
378 projects • 399 followers
I'm Arnov. I build, design, and experiment with tech—3D printing, PCB design, and retro consoles are my jam.

Comments