Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Help in processing...

Status
Not open for further replies.

koolguy

Active Member
Hi,

I am learning processing software here is the code for moving object..
i want to know how to make a file for opening it like flash file/gif images while saving/exporting it it is not doing as i want the processing software window open.


Code:
float x=200;
float y=100;
float speed=2;

void setup(){
  size(200,200);
}
void draw(){
  background(255);
  move();
  display();
}
void move() {
  x=x+speed;
  if (x>width){
    x=0 ;
  }}
  void display(){
    fill(20);
    rect(x,y,30,20);}
 
Problem is you're trying to run too many races at the same time. Try to focus on one project or problem at a time until you understand it.

I'm tackling XC8 for the PIC, I've never programmed in C before but after 5 days I'm starting to get the hang of it.
 
Processing If the OP would have a look there's examples to use processing with the com port.
And it's user base is big. But what do I know lol. But Bills right the OP has too many irons in the fire.

I would get one thing down then the next.
 
Hi,

I was testing serial communication in processing using PIC16f877 can we use pic with processing? because nothing was happening in screen as per code changing value from UART the color will changes..

Code:
import processing.serial.*;
Serial port;
float brightness = 0;


void setup()
{
  size(1200, 600); //Set size of the window
  port = new Serial(this, "COM6", 9600); //change "COM11" to the usb port, you are using
  port.bufferUntil('\n'); //wait for a value to appear in the Serial monitor

}

void draw()
{

  background(0, 0, brightness);
 
}
void serialEvent (Serial port)
{ 
  brightness = float(port.readStringUntil('\n'));
   
}
Code:
#include <htc.h>
__CONFIG(LVP_OFF & BOREN_OFF & PWRTE_ON & WDTE_OFF & FOSC_HS);
#define _XTAL_FREQ 20000000

void  HSerinit(void), HseroutString(unsigned char* str), Hserout(unsigned char ch);
 
 void main(void)                        // program entry  
   {  
   TRISB=0x00;
   unsigned char ch=0 ;         // <- LOOK HERE.
   ADCON1 = 0x6;                    // Analogue off    
   HSerinit();      
  __delay_ms(150); 
 
while(1){
ch=0;
for(char i=0;i<100;i++){
ch=ch+20;

 Hserout(ch);
__delay_ms(400);
} 
 
}
	}




void HSerinit()
	{
    TRISC = 0x80;                    // TX was an input!
    SPBRG = 129;                    // 20Mhz xtal 9600 BAUD
    TXSTA = 0x24;                    // TXEN and BRGH
    RCSTA = 0x90;                    // SPEN and CREN
	}

void Hserout(unsigned char ch)
	{
	while(!TXIF);
	TXREG = ch;	
	}

	
	}


showing this error on processing window..

Display 0 does not exist, using the default display instead.
WARNING: RXTX Version mismatch
Jar version = RXTX-2.2pre1
native lib Version = RXTX-2.2pre2
 
Last edited:
You have to set this to match the comport your using and make sure you load the right drivers
Code:
port = new Serial(this, "COM6", 9600)
 
You have to set this to match the comport your using and make sure you load the right drivers
Code:
port = new Serial(this, "COM6", 9600)

Try google LOL
the rxtx communication jar file in the arduino and the serial communication jar in the arduino is slightly different than that of processing 1.5.1


you need to go into the arduino source package and copy that rxtx jar file and the native library for it based on your system platform into the processing built in serial library


I'm on a mac so for me its basically this:
right click show package contents on arduino then Contents > resources > java > rxtxcomm.jar and librxtxSerial.jnilib, copy those files into Processing > contents > resources > java > modes > java > libraries > serial then paste the rxtxcomm.jar in to that folder and then the librxtxSerial.jnilib into the macosx folder.

I recommend moving the files in there to other directories on your computer first and once you drop them in the Processing serial library, quit and restart to test it.


These file paths will be different if you are not on a mac but basically you need to replace the rxtxcomm.jar in processing and its native interface with the ones in arduino and you will be set regardless of your platform
 
HI,

I have downloaded the file RXTXcomm.jar in this folder it contain..gnu folder and META-INF i have copied it to Navigate to the Processing folder>modes>java>libraries>serial>library
but the error remain there why?????
 
Hi,


I am suing processing 1.5 with XP 32bit and i want to do serial comm of uC using PIC16F877 with processing and tested that pic uC code in serial terminal window it is transferring 0xff and 0x02 with delay in between to see the color diff on processing window there is no error in both code but then also it is not changing window color why??


Code:
# #include <htc.h>
#  __CONFIG(LVP_OFF & BOREN_OFF & PWRTE_ON & WDTE_OFF & FOSC_HS);
#  #define _XTAL_FREQ 20000000
#   void  HSerinit(void), HseroutString(unsigned char* str), Hserout(unsigned char ch);
#  void main(void)                        // program entry
#  {
#      TRISB=0x00;   
#        // <- LOOK HERE.
#  ADCON1 = 0x6;                    // Analogue off
#  HSerinit();
#  __delay_ms(150);
# unsigned char ch=0;
#  while(1)
# {
# ch=0xff ; 
#    Hserout(ch);
# __delay_ms(500);
#  ch=0x02 ; 
#    Hserout(ch);
# __delay_ms(500);
# }
#  }            
# void HSerinit()  
#   {
#  TRISC = 0x80;                    // TX was an input!    
# SPBRG = 129;                    // 20Mhz xtal 9600 BAUD
#     TXSTA = 0x24;                    // TXEN and BRGH
#     RCSTA = 0x90;                    // SPEN and CREN  
#   }
#  void Hserout(unsigned char ch) 
#    {   
#  while(!TXIF);   
#  TXREG = ch;    
#     }

Code:
   1. import processing.serial.*;
   2.  Serial port; float brightness = 00;
   3.  void setup()
   4. {
   5.  size(1200, 600); //Set size of the window
   6.   port = new Serial(this, "COM11", 9600); //change "COM11" to the usb port, you are using
   7.   port.bufferUntil('\n'); //wait for a value to appear in the Serial monitor
   8.   }
   9.   void draw()
  10.  {     background(0, 0, brightness);
  11.  }
  12. void serialEvent (Serial port)
  13. {
  14.  brightness = float(port.readStringUntil('\n'));
  15.   }
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top