Skip to content

Instantly share code, notes, and snippets.

@haveyouwantto
haveyouwantto / music.py
Last active January 2, 2025 14:32
ESP32 PWM
from time import sleep
from machine import Pin, PWM
import struct
# Function to calculate the frequency of a musical note based on its MIDI note number
def get_freq(note):
return int(440 * 2 ** ((note - 69) / 12.0))
# Lists for note offsets and PWM duty values
offset = [0, -24, 0, 0, 0, -12, 12, 24, 36, 0, 0, 0, 0, 0, 0, 0]
@haveyouwantto
haveyouwantto / picojmbox.py
Created May 25, 2023 07:59
PicoJMBox for ESP32
import network
import uos
import usocket as socket
import ujson as json
import _thread
from time import sleep_ms
ap = network.WLAN(network.AP_IF)
ap.active(True)
ap.config(essid="PicoJMBox")
@haveyouwantto
haveyouwantto / aled.py
Last active November 29, 2022 02:18
Raspberry Pi Bluetooth Audio LED (with ws281x)
#!/usr/bin/python3
import colorsys
import subprocess
import traceback
import math
import numpy as np
from rpi_ws281x import Color, PixelStrip
#include <WeELF328P.h>
WeBuzzer buzzer(OnBoard_Buzzer);
void setup(){
pinMode(2, INPUT);
}
@haveyouwantto
haveyouwantto / index.html
Last active May 15, 2021 18:44
Minecraft Function Generator
<html>
<body>
<script type="text/javascript">
function sier(){
let z = 0
for (z = -50; z < 50; z++) {
let zs = z
draw(z)
}
@haveyouwantto
haveyouwantto / functions.js
Last active March 2, 2019 15:57
Random JS
function g(num) {
var a = [];
for (var i = 1; i < num + 1; i++) {
if (num % i == 0) {
a=a.concat(i);
}
}
return a;
};
var system = client.registerSystem(0, 0);
system.initialize = function () {
};
system.update = function () {
};
//For Microsoft Makecode
player.onChat("run", function () {
let xpos = player.position().getValue(Axis.X)
let ypos = player.position().getValue(Axis.Y)
let zpos = player.position().getValue(Axis.Z)
let z = 0
for (z = -50; z < 50; z++) {
loops.runInBackground(function () {
let zs = z
draw(xpos, ypos, zpos, z)
package tk.hywt.piano;
import javax.sound.midi.MidiChannel;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.Synthesizer;
import tk.hywt.piano.Notes;
public class Main {
public static void main(String[] args) throws MidiUnavailableException, InterruptedException {
@haveyouwantto
haveyouwantto / cmd(1.12).txt
Last active September 29, 2018 13:45
无聊的命令
/summon falling_block ~ ~1 ~ {
Time:10,Tile:1,Passengers:[
{id:falling_block,Time:10,Tile:137,TileEntityData:{Command:"/say 1"},Passengers:[
{id:falling_block,Time:10,Tile:152,Passengers:[
{id:falling_block,Time:10,Tile:137,TileEntityData:{Command:"/say 2"},Passengers:[
{id:falling_block,Time:10,Tile:152,Passengers:[
{id:falling_block,Time:10,Tile:137,TileEntityData:{Command:"/say 3"},Passengers:[
{id:falling_block,Time:10,Tile:152,Passengers:[
{id:falling_block,Time:10,Tile:137,TileEntityData:{Command:"/say 4"},Passengers:[
{id:falling_block,Time:10,Tile:152,Passengers:[