Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am rahji on github.
  • I am robduarte (https://keybase.io/robduarte) on keybase.
  • I have a public key ASDfOppsxrmJnIwGnb3Cz-oJLcL_JomvBMIST9TWUG9PMgo

To claim this, I am signing this object:

@rahji
rahji / arduino_android_demo
Created June 22, 2020 17:13
Simple Arduino example that uses Serial comms as its interface
/* A simple arduino sketch that accepts one of three character-commands
* via the serial port: 0 to turn the LED off, 1 to turn it on, 2 to blink it
*/
// keep track of the "state": 0, 1, or 2
char currentState = '0';
char previousState = ' ';
// a separate flag to keep track of whether the LED
// should be blinking at the moment
#!/bin/bash
# countdown timer, for use with OBS Studio or the like
# writes a mm:ss countdown to a file every second
# Usage: ./countdown.sh SECS FILENAME
### CAUTION: there is no error checking at all
### and FILENAME WILL GET CLOBBERED!
@rahji
rahji / udp.pde
Created May 8, 2021 23:08
UDP example for Processing
import java.net.*;
import java.io.*;
import java.util.Arrays;
// from https://discourse.processing.org/t/receive-udp-packets/19832
DatagramSocket socket;
DatagramPacket packet;
byte[] buf = new byte[12]; //Set your buffer size as desired
ctx = Graphics.two()
let x = 0
onframe = function(timestamp) {
const w = Graphics.canvas.width, h = Graphics.canvas.height
ctx.strokeStyle = 'green'
ctx.clearRect( 0,0,w,h )
const size = 300
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Backwards Text Test</title>
<style>
.backwards {
@rahji
rahji / main.cc
Created January 29, 2023 16:46
LCD Display example code for PlatformIO
/*
LiquidCrystal Library - Hello World
Demonstrates the use a 16x2 LCD display. The LiquidCrystal
library works with all LCD displays that are compatible with the
Hitachi HD44780 driver. There are many of them out there, and you
can usually tell them by the 16-pin interface.
This sketch prints "Hello World!" to the LCD
and shows the time.
@rahji
rahji / main.cpp
Created January 29, 2023 18:46
DHT11 sensor lab
#include <Arduino.h>
#include <Wire.h>
#include <dht_nonblocking.h>
#define DHT_SENSOR_TYPE DHT_TYPE_11
static const int DHT_SENSOR_PIN = 2;
DHT_nonblocking dht_sensor( DHT_SENSOR_PIN, DHT_SENSOR_TYPE );
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);
@rahji
rahji / main.cpp
Last active February 27, 2023 16:29
RFID Code for Kat
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
boolean successfullyReadtheFirstCard = false;
boolean card1Read, card2Read, card3Read;
@rahji
rahji / goboard.txt
Last active April 12, 2023 23:41
Go game board (Goban) generator for laser cutting and engraving
// gramlanguage.com
size = 19 // 19 or 13 or 9
margin = 30 // board cutout margin/padding
// ---------------------------------------
size = size - 1
w = 22
h = 23.7