Right OK, I fear I'm rapidly out of my depth so grateful for any help!
I'm running a processing sketch on a pi 3 attached to a touch screen. As the screen is touched its drawing a line with the finger. Whilst doing that its printing the X , Y coordinates to the console in processing.
What i'm trying to do is get these coordinates to the arduino. The arduino has an uploaded HEX file onto the onboard chip. These are controlling 2 steppers. So if you have the arduino IDE running you type X10 into the serial monitor and in drives the stepper. So, the arduino is tied up with grbl so I can't run a sketch to look for data or act on data being sent.
I some how need to get the X Y data to the arduino. Is the best way through a USB cable? I've followed this useful link to set up the serial arduino command setup
(Processing 2.1 + Oracle Java + Raspberry Pi + Serial + Arduino = ☺ – We Saw a Chicken …)
and have data going from processing to arduino
this works as a test flashing the arduino light on and off
import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
int ledPin = 13;
void setup()
{
println(Arduino.list());
arduino = new Arduino(this, Arduino.list()[0], 9600);
arduino.pinMode(ledPin, Arduino.OUTPUT);
}
void draw()
{
arduino.digitalWrite(ledPin, Arduino.HIGH);
delay(1000);
arduino.digitalWrite(ledPin, Arduino.LOW);
delay(1000);
}
this is also working with my attempt to get X10 to the arduino grbl shield but no X10 going to arduino. mouse released in processing square LED on arduino blinks.
import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
void setup()
{
size (200,200);
println(Arduino.list());
arduino = new Arduino(this, Arduino.list()[0],9600);
}
void draw() {
background(100);
}
void mouseReleased(){
arduino.digitalWrite('X', 10);
}
heres the code for the processing sketch do far it works but no data going to the serial of the arduino, should I be using digitalwrite to write the data into the arduino serial monitor, should i not be using USB but rather TX RX?
import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
void setup()
{
size (200,200);
println(Arduino.list());
arduino = new Arduino(this, Arduino.list()[0],9600);
}
void setup()
{
size(200,200); //make our canvas 200 x 200 pixels big
String portName = Serial.list()[0]; //change the 0 to a 1 or 2 etc. to match your port
myPort = new Serial(this, portName, 9600);
}
void draw() {
stroke(255);
if (mousePressed == true) {
line(mouseX, mouseY, pmouseX, pmouseY);
}
}
void mousePressed ()
{
println("PRESSED x:" +mouseX + " y:" + mouseY);
}
void mouseDragged ()
{
println("G01 x" +mouseX + " y" + mouseY + " F100");
}
Thankyou in advance for any help. Loving the whole coding hardware... but struggling with the depth of knowledge required and coding logic!