0%
0%

# Make and Feel Virtual Drawings

What if you could draw on your computer by feeling it ? Make such an interface!

Similar projects worth following
563 views
Learn to make a new haptic (Haptic perception is the process of recognizing objects through touch) device with Arduino! Here I can feel the slope of part of the drawing being touched using a servo motor. I made this for my blind friends...and for and to try out a new way of drawing! Here I used Servo motors and Arduino Uno and hacked a mouse to make our device.

Hypothesis:

While drawing blindfolded, a square in the haptic perception becomes radically different on paper. This is a problem in bridging the gap between haptic perception and the drawing interface we use. I've developed a device that gives tactile output of curvature of a drawing at a point by changing the slope of a servo motor fan. So, when drawn using this interface, the memory stores all the slopes at different points and accurately draws the shape imagined in our mind (or as we think it perceives it).

I need help to improve the program algorithm. Anyone up?

Also, I'm planning to make an interactive HapticBox- which is nothing but a more interactive and usable form of this project.

• ### To Do List

PART I:

Till now, I have built apparatus for 2D drawings.

Need further improvement of motor rotation control (accuracy).

Improve the algorithm for calculating slope of the drawing when we are 'touching' the drawing.

Improve usability, ergonomics and product design.

PART II (to be done):

3D drawing interface implementation.

• 1
Step 1

## Start drawing on Processing

First lets create a code on Processing, which lets you draw freehand on the computer.

Here is the processing code:

int prevX=mouseX, prevY=mouseY; //to record previous position of mouse pointer

void setup() { size(800, 800);

}

void draw() { if(mousePressed)

{stroke(0);

strokeWeight(20);

smooth();

line(prevX, prevY, mouseX, mouseY);

prevX=mouseX;

prevY=mouseY;

} }

Now you can start drawing using your own code!

• 2
Step 2

## Make Processing control Arduino

THE FINAL PROGRAM:

So,you have started drawing on Processing. Now, you'll 'feel' the drawing!

Imagine you are blind (remember, this device was invented for blind people to draw on computers):

How would you feel a raised line drawing ( where you follow the thread with your finger )? See picture for example.

At any point, the thread shows you an angle, that's how we'll make the servo motor act.

For that, we need to find the slope of the drawing at the point where the mouse is.

This angle will be sent to servo motor through Arduino.

Now, to get Arduino and Processing to talk to each other we need to download libraries for both softwares.

Import Arduino Library for Processing.http://playground.arduino.cc/Interfacing/Processin...

Go to the link above and import Firmata library for Arduino.

Now connect Arduino Uno to your computer.

First, open Arduino software and upload Standard Firmata from Examples option.

import processing.serial.*;

import cc.arduino.*;

Arduino arduino;

import ddf.minim.*;

Minim minim; AudioPlayer player;

int t=0;

int nn=0, d=0, p=0;

int prevX=mouseX, prevY=mouseY;

float x,y,m,atx=0, a=0;

void setup()

{

minim = new Minim(this);

player = minim.loadFile("Kenny G - Miracles The Holiday Album - 04 - Silent Night .mp3"); // instead of this music file, you can load your own by writing the file name and putting the music file in the processing sketch folder

size(800, 800); // change the size of the screen where you draw background(255);

println(Arduino.list());

arduino = new Arduino(this, Arduino.list()[0], 57600); //Modify this line, by changing the "0" to the index of the serial port corresponding to your Arduino board (as it appears in the list printed in the black screen at the bottom).

arduino.pinMode(4, Arduino.SERVO); // change the pin number if you want to attach the servo to another one }

void draw()

{

if(mousePressed)

{

stroke(0);

strokeWeight(10);

smooth();

nn++;

if (nn==10) {

line(prevX, prevY, mouseX, mouseY);

x = (mouseX-prevX);

y = (mouseY-prevY);

if (x!=0)

{

m = -y / x;

}

else{ }

atx=57.27*atan(m);

if((x<0 && y<0) || (x>0 && y>0))

{

d=abs(round(atx));

} if((x>0 && y<0) || (x<0 && y>0))

{

d=180-abs(round(atx));

}

arduino.servoWrite(4,d ); //Write a value to the servos, telling them to go to the corresponding angle (for standard servos)

println(d); nn = 0;

prevX=mouseX; prevY=mouseY;

}}

else

{

color a = get(mouseX, mouseY);

if(color(a)==color(0))

{

java.awt.Toolkit.getDefaultToolkit().beep();;

delay(15);

p++;

if(p==2)

{

x = (mouseX-prevX);

y = (mouseY-prevY);

if (x!=0) { m = -y / x;

}

else

{ }

atx=57.27*atan(m);

if((x<0 && y<0) || (x>0 && y>0))

{

d=abs(round(atx));

}

if((x>0 && y<0) || (x<0 && y>0))

{

d=180-abs(round(atx));

}

arduino.servoWrite(4,d );

println(d); p=0;

prevX=mouseX;

prevY=mouseY;}}

else {}

prevX=mouseX; prevY=mouseY;

}

}

• 3
Step 3

## Power to Servo motor

So, we've written the code. Now start all wiring stuff:

We have two options:

Give 5V to servo motor from Arduino.Here, you can connect the servo motor ( attach a small fan to the motor ) to Arduino Uno. Servo motor has 3 wires: Connect Brown wire to GND pin. Yellow wire to digital pin 4. Red wire to 5V pin.

Or

As powering a servo motor through Arduino isn't always a good idea. As shown in the picture, we can supply 5 Volts to the servo, through external 5V DC Adapter.

Share

## Discussions

abhinavnowinew wrote 04/28/2014 at 02:52 point
thanks niazangels for the support!!!

Are you sure? yes | no

niazangels wrote 04/27/2014 at 17:17 point
Good going! Love that you hit a spot missed by a lot of hackers. Continue your efforts and keep us posted :)

Are you sure? yes | no

# Does this project spark your interest?

Become a member to follow this project and never miss any updates