Skip to content

Instantly share code, notes, and snippets.

View Leowbattle's full-sized avatar

Leo Battle Leowbattle

  • England
View GitHub Profile
@Leowbattle
Leowbattle / morse.py
Created April 7, 2024 15:03
Morse code transmitter for Raspberry Pi Pico
from machine import Pin
import utime
buzzer = Pin(16, Pin.OUT)
dit_time = 0.05
dah_time = dit_time * 3
message = "SOS WE ARE SINKING"
@Leowbattle
Leowbattle / Pico 7 Segment.py
Created March 29, 2024 21:44
Python script for Raspberry Pi Pico for displaying numbers on a 7-segment display. The number shown is incremented every time a button is pushed, and resets back to 0 when it goes above 9.
from machine import Pin
import utime
p = [Pin(i, Pin.OUT) for i in range(7)]
button = Pin(28, Pin.IN, Pin.PULL_DOWN)
digits = [
0b0111111,
0b0000110,
0b1011011,
@Leowbattle
Leowbattle / BVP.ipynb
Last active September 15, 2023 22:40
Boundary Value Problem
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Leowbattle
Leowbattle / pendulum.f90
Created September 9, 2023 11:23
Simulation of a simple pendulum in Fortran using the semi-implicit Euler method
program pendulum
implicit none
real :: time, dt, g, l, y, v
integer :: n, i
read (*,*) time, dt, g, l, y, v
n = ceiling(time / dt)
do i=2,n
#include <math.h>
#include <stdlib.h>
#include <raylib.h>
#include <raymath.h>
typedef struct Hermite {
float x;
float y;
float d;
} Hermite;
#include <stdio.h>
typedef struct mat4 {
float m[16];
} mat4;
typedef struct vec3 {
float x;
float y;
float z;
#include <stdint.h>
#include <math.h>
#define STB_IMAGE_WRITE_IMPLEMENTATION
#include "stb_image_write.h"
struct rgb {
uint8_t r;
uint8_t g;
uint8_t b;
@Leowbattle
Leowbattle / MainProgram.java
Created March 13, 2023 16:26
Implementing natural numbers with Peano arithmetic in Java 😎
public class MainProgram {
public static void main(String[] args) {
Nat n1 = Nat.int2Nat(10);
Nat n2 = Nat.int2Nat(20);
Nat n3 = n1.add(n2);
int x = Nat.nat2Int(n3);
System.out.println(x);
#include <iostream>
#include <vector>
#include <optional>
#include <functional>
#include <cctype>
using namespace std;
struct unit {
@Leowbattle
Leowbattle / bilinear.c
Created January 22, 2023 16:13
bilinear.c
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
#define STB_IMAGE_WRITE_IMPLEMENTATION