×

SparkFun will be closed Monday 7/4/2022 for the 4th of July holiday. Orders placed after 2 pm MT on Friday 7/1/2022 will be processed on Tuesday 7/6/2022. SparkFun Support will also resume on Tuesday 7/6/2022. Have a safe holiday!

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 :(