Processing and Serial.print Error
in
Integration and Hardware
•
1 year ago
Hi so Im working out a new code that sends the serial of a letter to the arduino but I keep getting an error in Serial.print.
The error states: The function print(char) does not exist.
The code itself has "Serial." in the color black and "print" in the color orange.
Here is the code:
- import processing.serial.*; //Import the serial library into your sketch
- import cc.arduino.*; //Import the Arduino-Firmata library into your sketch
- Arduino arduino; //Create an instance of Arduino named arduino (can be any name)
- char e;
- int ledPin;
- char serial;
- Serial scope;
- String adaptor= "/dev/tty.usbmodem1a21";
- void portConnect(){
- int portNumber = 99;
- String [] ports;
- println(Serial.list());
- ports = Serial.list();
- for(int j = 0; j< ports.length; j++) {
- if(adaptor.equals(Serial.list()[j])) portNumber = j;
- }
- if(portNumber == 99) portNumber = 0;
- String portName = Serial.list()[portNumber];
- println("Connected to "+portName);
- scope = new Serial(this, portName, 9600);
- scope.bufferUntil(10);
- }
- /*
- Serial scope; // Create object from Serial class
- //**************** Change this to match the device driver you are using *****************
- String adaptor = "/dev/tty.usbserial-FTEJUA6O"; // the name of the device driver to use change it to what you have
- // call this from setup()
- void portConnect(){ // Open the port that the controller is connected to
- // **********************************
- // if the device you are looking for is
- // not available the program will
- // connect to the first one in the list
- // ************************************
- int portNumber = 99;
- String [] ports;
- // println(Serial.list()); // uncomment for full list of serial devices
- ports = Serial.list();
- for(int j = 0; j< ports.length; j++) {
- if(adaptor.equals(Serial.list()[j])) portNumber = j;
- } // go through all ports
- if(portNumber == 99) portNumber = 0; // if we haven't found our port then connect to the first one
- String portName = Serial.list()[portNumber];
- println("Connected to "+portName);
- scope = new Serial(this, portName, 19200); // baud rate defined here
- scope.bufferUntil(10); // call serialEvent() every line feed
- }
- */
- void serialEvent(Serial scope) { // this gets called every time a line feed is received
- String recieved = scope.readString() ;
- println(recieved + " from serial port"); // show it at the bottom of the processing window
- // also do the stuff you want to do when you get things back from the arduino
- }
- void setup() {
- size(200, 200);
- print(arduino.list());
- arduino = new Arduino(this, Arduino.list()[0], 9600); //defines arduino our board and sets the communication rate
- arduino.pinMode(ledPin, Arduino.OUTPUT);
- }
- void keyPressed() {
- print(key);
- delay(10);
- switch (key) {
- case 'e':
- case 'E':
- Serial.print('e');
- break;
- case 'i':
- case 'I':
- Serial.print( 'i' );
- break;
- case 'q':
- case 'Q':
- Serial.print( 'q' );
- break;
- }
- };
- void keyReleased() {
- delay(10);
- switch (key) {
- case 'e':
- case 'E':
- Serial.print( 'z' );
- break;
- case 'i':
- case 'I':
- Serial.print( 'p');
- break;
- case 'q':
- case 'Q':
- Serial.print( 'l');
- break;
- }
- };
If you have any ideas what I am doing wrong, that would be greatly appreciated.
ALSO: I want to communicate this wirelessly (using xbee), what baud rate would you recommend for the best communication?
thanks, Matt
1