Member #919964

Member Since: March 26, 2017

Country: United States

  • This is my code for reading a file from PC and sending it to arduino // Processing code import processing.serial.*;

    Serial myPort;  // Create object from Serial class
    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);
    serialEvent( myPort);
    }
    void serialEvent (Serial myPort)
    {
    String[] lines = loadStrings("C:\\Users\\visma\\Desktop\\Project codes\\mydata.txt");
    //println("there are " + lines.length + " lines");
    for (int i = 0 ; i < lines.length; i++) {
    myPort.write(lines[i]);
    println(lines[i]);
    }
    }
    
    // Arduino Code
    #include<SoftwareSerial.h>
    char val;
    void setup() {
    Serial.begin(9600);
    }
    void loop() {
    if (Serial.available() > 0) {
    val = Serial.read();
    Serial.write(val); 
    Serial.print(val);
    }
    }
    

    I am not able to see anything on SerialPort kindly help !

  • make it [0]

  • I have done displaying the string from arduino to pc but it is showing "null" and then "hello world" displays any method to stop displaying "null" and stop the code when it reaches end of file.

No public wish lists :(