Enhancing my tattoo machine
Tags: hardware, arduino, c
Published: 2020-04-07 12:26:35

---
title: Enhancing my tattoo machine
published: true
description: Some open hardware projects for enhancing my tattoo machine
tags: hardware, arduino, C
cover_image: https://assets1.ello.co/uploads/asset/attachment/10459547/ello-optimized-15480607.jpg
---

The first time I saw a tattoo was in my ballet classroom. An older student had wings tattooed in the back, and I was amazed. Years later, when I was legally allowed I was tattooed for the first time, and I kept being fascinated by it, so even though I was studying tech, I wanted to be a tattooist as well in the future. Last year I got my tattooing certificate, and after using my own machine and see how other tattooist used their own while tattooing my body, I thought "Hey some of the most common issues could be helped using Arduino simple scripts". So in the end, I decided to start investigating on this a while ago on this, and started using some while practising. 

## Issue 1: The classic machine gets hot after a while

The machine gets very hot after several minutes drawing. It's wise to stop from time to time (also to relieve pain from the person being tattooed) but also to give a break to the tattoo machine. While I'm practising on fake skin, I forget about this because I'm too focused on the design and sometimes it gets really hot. For that, I made a temperature sensor attached to my machine with an alarm. As most Arduino alarms implies using vibrations, this wasn't an option for tattooing alarm, so I used a led. 

![](https://assets0.ello.co/uploads/asset/attachment/10459546/ello-optimized-13650e29.jpg)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/qup1yxhpy3eh9k8xhevy.jpg)

```
float temp;
int tempPin = 0;
int beep = 9;   

//Once I calibrated depending on the needle
int maquina_tatu = 10;

void setup() {
   Serial.begin(9600);
   pinMode(buxxerPin, OUTPUT);
   beep(50);
}

void beep(unsigned char delayms){

  analogWrite(buzzerPin, 20);                                      
  delay(delayms);                                                             
  analogWrite(buzzerPin ,0);             
  delay(delayms);
}

void loop() {
   temp = analogRead(tempPin);
   // read analog volt from sensor and save to variable temp
   temp = temp * 0.48828125; //convert to c
   // convert the analog volt to its temperature equivalent
   Serial.print("TEMPERATURE = ");
   Serial.print(temp); // display temperature value
   Serial.print("*C"); //I'm from Europe you know
   Serial.println();

   if(temp > maquina_tatu){
   	beep(50);
	delay(500);
	beep(50);
   }

   delay(1000); // update sensor reading each one second
}

```

When programming Arduino, we will write some variables regarding to the pins connected in the board, in this case we connected a digital pin tagged with '9' to the led and an analog pin tagged as 'A0' for the temperature sensor. 

Digital means it only accepts high or low values, while analog represent a whole range of values. We also have to have in mind our circuit has to begin and to end, this seems stupid but it's fundamental: It starts in Vcc and ends in GND (ground). I use this pikachu to explain it to my students:

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/4nkv97h54x3iufr1wka8.jpg)

In setup we will write how we want the board to be when we reset or connect the device. In this part we usually calibrate, add the Monitor Channel or specify which is an output and which is an input. It quite depends on the programmer, but that's mostly it. In loop we will write what we want to repeat while the device is on, is like the main function. We could also add other functions but these are the basics. 

## Issue 2: color picker

There are a wide range of colours for tattooing, did you know that depending on the colour it hurts more? White is the most painful due to the density. Anyway, maybe reading the colour range in a picture or an already done tattoo can make it easier to create the proper mixture or choosing the correct colour. For that I used a colour sensor, I firstly used it to emulate colours like a chameleon, to be honest, but hey recycling is good!

![](https://assets0.ello.co/uploads/asset/attachment/10459718/ello-optimized-3c8538ce.gif) 

For giving shape to the idea (without the led) I took this wonderful code from [droneworkshop](https://dronebotworkshop.com/).

```
// Include I2C Library
#include <Wire.h>
 
// Include Sparkfun ISL29125 Library
#include "SFE_ISL29125.h"
 
// Declare sensor object
SFE_ISL29125 RGB_sensor;
 
// Calibration values
 
unsigned int redlow = 0;
unsigned int redhigh = 0;
unsigned int greenlow = 0;
unsigned int greenhigh = 0;
unsigned int bluelow = 0;
unsigned int bluehigh = 0;
 
// Declare RGB Values
int redVal = 0;
int greenVal = 0;
int blueVal = 0;
 
 
void setup()
{
  // Initialize serial communication
  Serial.begin(115200);
 
  // Initialize the ISL29125 with simple configuration so it starts sampling
  if (RGB_sensor.init())
  {
    Serial.println("Sensor Initialization Successful\n\r");
  }
}
 
 
void loop()
{
  // Read sensor values (16 bit integers)
  unsigned int red = RGB_sensor.readRed();
  unsigned int green = RGB_sensor.readGreen();
  unsigned int blue = RGB_sensor.readBlue();
  
  // Convert to RGB values
  int redV = map(red, redlow, redhigh, 0, 255);
  int greenV = map(green, greenlow, greenhigh, 0, 255);
  int blueV = map(blue, bluelow, bluehigh, 0, 255);
  
  // Constrain to values of 0-255
  redVal = constrain(redV, 0, 255);
  greenVal = constrain(greenV, 0, 255);
  blueVal = constrain(blueV, 0, 255);
     
  Serial.print("Red: "); 
  Serial.print(redVal);
  Serial.print(" - Green: ");
  Serial.print(greenVal);
  Serial.print(" - Blue: "); 
  Serial.println(blueVal);
  
  // Delay 2 seconds for sensor to stabilize
  delay(2000);
}
```
But hey, let's remember mixing light and mixing paint is different! even though RGB is mostly used to explain light colours, it could be handy to learn about tattoo colours, but being careful when mixing!

In this case we needed to use an external library than can be attached using Arduino IDE and declaring a sensor object. This also happens with other devices such as motors, 7 segment leds and more. 

For now these are the projects I've been using, but I will totally make more once I get the chance. I don't know is someone would trust me using an arduino-modified machine but hey! it's a lot of fun when practising at home.