-
1Step 1
Start drawing on Processing
First lets create a code on Processing, which lets you draw freehand on the computer.
Download Processing from https://www.processing.org/download/ .
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!
-
2Step 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.
Upload this Processing code:
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;
}
}
-
3Step 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.
-
4Step 4
Hack a mouse (optional)
Open the casing of the mouse, and remove the scroll roller.
Now, you should have space to place the servo motor like in the picture.
To paste servo motor on the mouse board, use a glue gun or double sided tape.
Now, there should be a plastic lens with a small prism, tape it with the mouse board at it's initial position.
Additional:
You can play with the mouse like this:
Go to this amazing instructable by neelandan:
http://www.instructables.com/id/Mouse-Cam/
Or see how the lens works, it magnifies the surface image for the small camera inside. This camera calculates the speed at which the surface moves. You can know how to hack the camera of the mouse here:
-
5Step 5
Ready to use!
YouTube video of : A prototype I made. (This one is without hacking a mouse).
You can try to draw a circle using this interface, keeping your eyes closed. Check if you can draw closed loops with this interface, which you wouldn't be able to draw blindfolded.
I found this DIY interface not being much helpful in integrating length and curvature, to give the proposed feedback. But, this definitely aids drawing on computer by blind people.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.