Arduino passes the value to the Processing display through the serial port.

Arduino passes the value to the Processing display through the serial port.

Arduino side code:

int red=255; //Create variables to store the data you need to send
int green = 2;
int blue = 3;
void setup()
  Serial.begin(9600);//Define a data transfer rate of 9600 bits
void loop()

The above red, green, blue can be replaced with the value obtained by the color sensor in practical applications.

Processing code:

import processing.serial.*;//Introducing the serial library
int r = 0;
int g = 0;
int b = 0;
Serial myPort;//Create a Serial object called "myPort"
void setup() {
  myPort = new Serial(this,"COM7", 9600);
  myPort.bufferUntil('\n');  //buffer until meet '\n', then call the event listener
  //Define myPort's port and data transfer rate
  //Should be consistent with Arduino
void draw() {
  fill(r, g, b);
  rect(30, 20, 55, 55);
//listen to the event. when buffer filled, run this method
void serialEvent(Serial p) {
  String inString = p.readString();
  String[] list = split(inString, ',');
// list[0] is now "Chernenko", list[1] is "Andropov"...
  r = int(list[0]);
  g = int(list[1]);
  b = int(list[2]);

50 Replies to “Arduino passes the value to the Processing display through the serial port.”

  1. Here at Leslie’s Pugsland Breeder, Our beautiful fawn pug has given birth to 4 healthy Pug puppies.
    She is our beloved family dog and this is her 1st litter.
    Both mum and dad are AKC registered with 5 gen pedigree certificate. Both from Top Champion bloodlines.Mum and Dad can be seen. Puppies have been wormed weeks 2,4,6,8 and will have had a flea preventative treatment before leaving us.
    They will have their vet check, 1st vaccinations and microchip.
    To view all available puppies and recent pictures, Search us in google as LESLIE’S PUGSLAND BREEDER or click on our website link bellow :

    Pug Puppies for sale | pug for sale near me | pug puppy for sale | pug puppy | pug for sale | pug puppies for sale in va | black pug puppies for sale

  2. Pingback: Stargazing
  3. Pingback: 안전카지노
  4. Pingback: omiqq
  5. Pingback: Royal Online
  6. Pingback: w88 casino review
  7. Pingback: Buy CBD Products
  8. Pingback: crush switches
  9. Pingback: boyaqq
  10. Pingback: rajapoker88
  11. Pingback:
  12. Pingback:
  13. Pingback: rajaqq
  14. Pingback: Malia
  15. Pingback: Vivian
  16. Pingback:
  17. Pingback: sales training
  18. Pingback: wire qwest
  19. Pingback: fowling rules
  20. Pingback: duratrans
  21. Pingback: rajawali qq
  22. Pingback: musim qq
  23. Pingback: pasar poker
  24. Pingback: mejaqq
  25. Pingback: qiuqiu99
  26. Pingback:
  27. Pingback: link vao w88
  28. Pingback: Bildemontering
  29. Pingback: sahabatqq
  30. Pingback: Hot Wife Captions
  31. Pingback: New Moon Spells
  32. Pingback: poker 99
  33. Pingback: đăng ký fun88
  34. Pingback: meja qq

Leave a Reply