ATtiny85 based strike depth sensor for training accuracy

Accuracy in martial arts is one of the most important feature, which the practitioners finds themselves struggling to achieve. Usually our teachers are the ones telling us when we are not accurate enough and then we might try to use tools like filming our selves in order to find this accuracy by ourself.

Since I am a huge fan of accurate technique, I wanted to create some tools for helping myself. I have been filming myself but the feedback from the video comes always too late. Usually I have the change to watch the videos during the next day and that is way too late in order to make a change during that training session.

Something that gives immediate feedback is needed. Another person watching would be a great way to achieve this requirement but there is not enough people around. Thus I decided to use Arduino, the hardware prototyping board and build a sensor for giving me instant feedback of a certain, very limited point of view.

This example code is used within the hardware and it essentially turns on green or red light depending of which part of the circuit became in contact via rubbed band. The sensor is used to check how deep a certain kind of strike with a wooden training weapon is going. It is supposed to make the first two rubber bands to touch each other but not the third one. The light will stay on for a second or so in order to show what just happened.

const int buttonA =  1;
const int buttonB =  2;
const int ledG = 3;
const int ledR = 4;
const int timeout = 1200; // ms

int redState = LOW;
int greenState = LOW;

int stateA = LOW;
int stateB = LOW;

// Until which millisecond time to wait until turn off led
long waitR = 0;
long waitG = 0;

void setup() {
  pinMode(ledG, OUTPUT);
  pinMode(ledR, OUTPUT);

  pinMode(buttonA, INPUT);
  pinMode(buttonB, INPUT);

void loop() {
  unsigned long current = millis();

  stateA = digitalRead(buttonA);
  stateB = digitalRead(buttonB);

  int redTest = HIGH;
  if (stateA == HIGH) {
    redTest = HIGH;
    waitR = current + timeout;
  else if (current > waitR) {
    redTest = LOW;
  if (redTest != redState) {
    redState = redTest;
    digitalWrite(ledR, redState);

  int greenTest = HIGH;
  if (stateB == HIGH) {
    greenTest = HIGH;
    waitG = current + timeout;
  else if (current > waitG) {
    greenTest = LOW;
  if (greenTest != greenState) {
    greenState = greenTest;
    digitalWrite(ledG, greenState);


The costs for the hardware are listed below:

  • Rechargeable battery AA x3, ~12 EUR
  • microtiny-board, ~10 EUR
  • Led, green and red, ~1 EUR
  • Resistors, ~1 EUR
  • Cables and connectors, ~2 EUR
  • Case and battery holder, ~7 EUR

Please note the microtiny board. It is Arduino compatible, but since it is based on the ATtiny85 circuit, it is cheaper than any Arduino board, but it has only 8 kilobytes of memory which make the software a bit more limited. In the case like this, the code above compiles to ~2 kb and therefore has no trouble of fitting to microtiny board.

Initially the prototyping was done in Arduino Uno R3 board and by setting up the circuit with push buttons on a breadboard.