loading

(HU)
A kurzor vezérlése 2 potméterrel arduino uno-val.

(EN)
The cursor control 2 potmeter with arduino uno.

Step 1: Bekötése/Assembly

(HU)
A 2 potméter helyes bekötése :

baloladli láb 5 V

középső láb analog

jobb oldali láb GND (föld)

Példa a képen.

(EN)

left pin 5 V

middle pin analog

right pin GND (ground)

Example in the picture

Step 2: Programozás/Programing

Arduino

int pot1;

int pot2;

void setup() {

Serial.begin(9600);

}

void loop() {

pot1 = analogRead(A0);

pot2 = analogRead(A1);

Serial.print( pot1 );

Serial.print(",");

Serial.println( pot2 );

delay(50);

}

Processing

import java.awt.*;

import javax.swing.SwingUtilities;

import java.awt.MouseInfo;

import java.awt.Point;

int xx =0, yy =0, nxx =0, nyy =0;

Robot eger; //(en) Robot mouse;

import processing.serial.*;
Serial port;

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

try{ port = new Serial(this,"com9",9600); //com= arduino com (Arduino ide -> Tool -> Port:"comX"

port.bufferUntil('\n');

} catch(Exception ex){

text("Nincs soros \n port komunikáció!",10,14); //(EN) " There is no serial port communication!"

} try {

eger = new Robot(); //(EN) mouse = new Robot();

} catch (AWTException e) {

println("Nem támogatott a robot class!"); exit(); //(EN) "Not Supported robot class!"

}

}void draw()

{ System.out.println("("+nxx+", "+nyy+")"); nxx=MouseInfo.getPointerInfo().getLocation().x; nyy=MouseInfo.getPointerInfo().getLocation().y;}

void serialEvent(Serial myPort) {
String bejovo = myPort.readStringUntil('\n');

if (bejovo != null) {

bejovo = trim(bejovo);

int[] potik = int(split(bejovo, ","));

if (potik.length >=2) {

if (nxx>xx+20 || nyy>yy+20 || nxx<xx-20||nyy<yy-20) { xx=nxx; yy=nyy;delay(250); }

else{
xx= potik[0]; yy=potik[1]; eger.mouseMove(xx,yy); }

} } }

Step 3: Bemutató\Premiere

It's not working with me!<br>it is working with mouse not with pot!<br>help me
<p>Thank you for this job and I want ask you how I can open downloaded file</p>
<p>Hello you need a processing program downloaded the side<a href="https://processing.org/download/?processing" rel="nofollow"> processing.org</a></p><p>( i have processing version 2.2.1 version)</p><p>and an Arduino to program on their side <a href="https://www.arduino.cc/en/Main/Software" rel="nofollow">arduino.cc</a></p><p>arduino program code to arduino ide </p><p>pocessing program code to processing program<br><br>in processing executable exe or mac os or sh linux files made <br>File -&gt; exportapplication-&gt; change your platform</p><p>I hope I could help you.<br></p>
<p>awesome job thank you (y)</p>
<p>Thank you :)</p>

About This Instructable

2,324views

13favorites

More by MátéL:Mouse control arduino uno on the pc 
Add instructable to: