Skip to content

Instantly share code, notes, and snippets.

View Hackin7's full-sized avatar
💭
Learning some new stuff & working on new projects!

Terence Chan Zun Mun Hackin7

💭
Learning some new stuff & working on new projects!
View GitHub Profile
@Hackin7
Hackin7 / BLEClient.java
Created July 22, 2023 16:46
2023_07_22 Notes
// Make sure to set up your imports properly before this
public class BLEClient {
private final static String TAG = BLEClient.class.getSimpleName();
public Context context;
private String mDeviceName;
private String mDeviceAddress;
private BluetoothLeService bluetoothService;
private ArrayList<ArrayList<BluetoothGattCharacteristic>> mGattCharacteristics =
new ArrayList<ArrayList<BluetoothGattCharacteristic>>();
@Hackin7
Hackin7 / RotatePiTFT.sh
Created December 13, 2020 08:57
Usage ./RotatePiTFT.sh (rotation 0/90/180/270) Meant to be used without rebooting. Was made quite long ago (2016) so not sure if still applicable
#!/bin/sh
echo 'sh RotatePiTFT.sh (rotation 0,90,180,270)'
if [$1 == '']; then
echo "Rotation (0,90,180,270):"
read rotation
else
rotation=$1
echo Rotation:
echo $rotation
fi
@Hackin7
Hackin7 / LEDMatrix.ino
Created December 11, 2020 08:15
For WS2812 LED Matrix. TechPals Season 2 Footpress
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h> // Required for 16 MHz Adafruit Trinket
#endif
#define PIN 0
#define LEDS 60
#define LED_WIDTH 6
#define LED_HEIGHT 10
Adafruit_NeoPixel pixels(LEDS, PIN, NEO_GRB + NEO_KHZ800);
@Hackin7
Hackin7 / ClockBox.cpp
Last active December 8, 2020 04:34
For the Clock and Sensor Box on Instructables
#include <Adafruit_GFX.h> // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library for ST7735
#include <Adafruit_ST7789.h> // Hardware-specific library for ST7789
#include <SPI.h>
#ifdef ADAFRUIT_HALLOWING
#define TFT_CS 39 // Hallowing display control pins: chip select
#define TFT_RST 37 // Display reset
#define TFT_DC 38 // Display data/command select
#define TFT_BACKLIGHT 7 // Display backlight pin
@Hackin7
Hackin7 / MultiThreadingJava.java
Created October 27, 2018 23:55
A Java multithreading demo about running 3 threads simultaneously
class Running implements Runnable {
private Thread t;
private String name;
Running( String threadName) {
name = threadName;
}
public void run() {
//String name = "A";
@Hackin7
Hackin7 / LightGunPIRSynth.js
Created July 23, 2018 11:47
From https://makecode.microbit.org , for a DIY toy gun with speaker and PIR sensor
//
let item = 0
input.onButtonPressed(Button.B, () => {
pins.digitalWritePin(DigitalPin.P13, 1)
item = 1
basic.showIcon(IconNames.Yes)
})
input.onButtonPressed(Button.A, () => {
music.playTone(440, music.beat(BeatFraction.Sixteenth))
item = 0
@Hackin7
Hackin7 / AIYQuoteMachine.py
Created July 16, 2018 14:53
Improved Google Assistant Demo for AIY project kit
#!/usr/bin/env python3
# Copyright 2017 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#