HI!

i am testing to send a simple script from the arduino to start serial communication.

on the arduino

 
void setup() {
  
  Serial.begin(9600);       // use the serial port
}
 
void loop() {
   Serial.println(1);
   delay(5000);
   Serial.println(2);
   delay(5000);
   Serial.println(3);
   delay(5000);  // delay to avoid overloading the serial port buffer
}
 
serial monitor arduino ide showing
 
1
2
3
 
serial monitor on MRL shows
 
000 224 224 000 000 224 000 224 000 000 224 224 000 000 224 000 
224 000 000 224 224 000 000 224 000 000 000 000 224 224 000 000 
224 000 224 000 000 224 224 000 000 224 000 224 000 000 224 224 
000 000 224 000 000 000 000 224 224 000 000 224 000 224 000 000 
224 224 000 000 224 000 224 000 000 224 224 000 000 224 000 000 
000 000 224 224 000 000 224 000 224 000 000 224 224 000 000 224 
000 224 000 000 224 224 000 000 224 000 000 000 000 224 224 000 
000 224 000 224 000 000 224 224 000 000 224 000 224 000 000 224 
224 000 000 224 000 000 000 000 224 224 000 000 224 000 224 000 
000 224 224 000 000 224 000 224 000 000 224 224 000 000 224 000 
000 000 000 224 224 000 000 224 000 224 000 000 224 224 000 000 
224 000 224 000 000 224 224 000 000 224 000 000 000 000 224 224 
000 000 224 000 224 000 000 224 224 000 000 224 000 224 000 000 
224 224 000 000 224 000 000 000 000 224 224 000 000 224 000 224 
000 000 224 224 000 000 224 000 224 000 000 224 224 000 000 224 
 
i would like to make this useful like a in a if statement or something
 
how should the programming be on the arduino and in MRL?

Mats

6 years 11 months ago

Hi 

Test with Serial.begin(57600);

 

 

 

Looks a little buggy @ 9600 - I see it working at 57600

 

Python Script - careful of the indentation

serial = Runtime.start('serial','Serial')
serial.connect('COM9')
python.subscribe('serial','publishRX')
def publishRX(data):
       print(chr(data))
       #print(data)
 
Arduino sketch
 
void setup() {
  
  Serial.begin(57600);       // use the serial port
}
 
void loop() {
   Serial.println(1);
   delay(5000);
   Serial.println(2);
   delay(5000);
   Serial.println(3);
   delay(5000);  // delay to avoid overloading the serial port buffer
}
 

You'll see extra carriage return line feeds in the MRL display, because it automatically adds them and the skech is putting them in too with the println

GroG

6 years 9 months ago

Ok, I put it on github because Alessandro (rightly so) - told me that its the right way (and deleted our code in comments)

I tested this in 119 - I had 2 Arduinos connected and it did not throw any errors.  I think it should work for you.

Let us know how it goes:

[[/home/Markus/Skin.py]]