Serial out

Hi
I’m trying to learn how to export through a serial port.
Not so sure how to do it, Serial DAT / Serial CHOP
I would like to do a very basic,

Button Toggle ‘ON’ >>>> Serial out ‘ASCII letter ‘H’’
Toggle ‘OFF’ >>>> Serial out ‘ASCII letter ‘L’’

Could someone be so gentle to create that example for me?
Thanks

Hello.
Perhaps the most direct way would be to setup a Serial DAT.

Then to send data through it, use the send command:

For example “send /project1/serial1 H”
or “send /project1/serial1 L”

Make sure the Serial DAT in /project1/serial1 has all the communication parameters
setup before sending data through it.
The DAT itself will show any bytes received from the cable. (not the script).

Ive set up a simple example with the above, triggering off a default button.
Let me know if you want more clarification.

Cheers
Rob.
simple_serial.tox (3.91 KB)

Hi Rob, thanks
Is it possible that I´m having a build issue?
Your file has been saved in 4917, I´m running 3715
If I loaded anyway, I have this error
“Cloned COMP must be the same type”
I will try with the commands also

Hi.
I think the 3715 build may be fine for the example above, but you could always use the latest experimental build: 4961. These builds may potentitally be less stable by nature, but include some enhancements to the send command.
Not sure where the Cloned message is originating from but it doesn’t affect the Serial functionality described here.

Cheers.
Rob.

Hi Rob, thanks again
With the experimental build everything seems to work, no more error messages.
But the example as it is, in the beginning didn’t work.
I changed the commands lines, taking out the “/”
‘send serialin1 H|L’ instead of ‘send /serialin1 H|L’
and now everything works perfectly well.
This example is the basic example of how to use serial communication between Touch and Arduino.
The button ON/OFF will turn ON/OFF the on board PIN13 LED, or a regular LED if one is attached to the Arduino PIN13.
I upload the .toe, if someone would like to give a try.
and while trying to upload the Arduino sketch I get this message “The extension pde is not allowed” so I paste the code here.

const int ledPin = 13; // the pin that the LED is attached to
int incomingByte; // a variable to read incoming serial data into

void setup() {
// initialize serial communication:
Serial.begin(9600);
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
}

void loop() {
// see if there’s incoming serial data:
if (Serial.available() > 0) {
// read the oldest byte in the serial buffer:
incomingByte = Serial.read();
// if it’s a capital H (ASCII 72), turn on the LED:
if (incomingByte == ‘H’) {
digitalWrite(ledPin, HIGH);
}
// if it’s an L (ASCII 76) turn off the LED:
if (incomingByte == ‘L’) {
digitalWrite(ledPin, LOW);
}
}
}

Cheers
P.
simple_serial2.toe (6.19 KB)

1 Like

Thats great to hear you’ve got it working.

One note on the difference between serialin1 and /serialin1

Both are just paths to the operator, so that needs to match where the operator sits.
You can use relative or absolute paths.
Absolute paths begin in the root component “/”.
Relative paths begin from the current component.
Too see the current folder type pc (Stands for: print component)
examples:
/serialin1
/project1/serialin1
/project1/base1/serialin1
…/project2/serialin1
etc.

Cheers,
Rob.