<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with arduino+processing - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=arduino%2Bprocessing</link>
      <pubDate>Sun, 08 Aug 2021 18:32:52 +0000</pubDate>
         <description>Tagged with arduino+processing - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedarduino%2Bprocessing/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>real time graph plotting using processing</title>
      <link>https://forum.processing.org/two/discussion/23083/real-time-graph-plotting-using-processing</link>
      <pubDate>Fri, 16 Jun 2017 05:34:48 +0000</pubDate>
      <dc:creator>drocobeth</dc:creator>
      <guid isPermaLink="false">23083@/two/discussions</guid>
      <description><![CDATA[<p><img src="" alt="" /><img src="" alt="" />i have to plot a graph in processing by the feedback from encoder motors of the bot. so i have two variables basically left motor encoder and right motor encoder. i planned to vary on in x-axis and another in y-axis. while i went through some of the codes on internet i found that, almost everyone has written the graph part code in serial event itself? so my first doubt is why do they write it in serial event() function rather than void draw()? another thing is when i tried to write my code for graph in void draw() it had a pseudo code something like this:</p>

<pre><code>           xpos1=0,ypos1=height;
        void draw():
         line(xpos1,ypos1,xpos,height-ypos);// obviously the data(xpos,ypos) is mapped with the width and height of the processing ide window.
            xpos1=xpos;
            ypos1=height-ypos;
            if(xpos1&gt;=width)
            {
              xpos1=0;
            }
            if(ypos1&gt;=height)
            {
              ypos1=0;
            }
</code></pre>

<p>so i get to see only a small dot traversing on processing ide window and i cannot see the older path that my line has travelled which in the case of the sites which i described when wrote the similar piece of code in serial event() they had a whole graph getting made on the processing window. where am i getting wrong? please help me also is there any alternative to  plot the graph using void draw()?i want to vary both xpos as well as ypos as i get two feedbacks form left motor and right motor. please help with the detailed answers.
<img src="https://forum.processing.org/two/uploads/imageupload/672/ZJ3Y2V4V3SLH.png" alt="graph" title="graph" />
screenshot of my attempted graph in different frames<img src="https://arduining.files.wordpress.com/2013/08/graph_example.jpg?w=768&amp;h=529" alt="" />
screenshot of one of the graphs made by somewhat the similar code displayed above but written in the serial event() available on the internet:</p>
]]></description>
   </item>
   <item>
      <title>Send values from Processing sliders to Arduino Mega</title>
      <link>https://forum.processing.org/two/discussion/11627/send-values-from-processing-sliders-to-arduino-mega</link>
      <pubDate>Thu, 09 Jul 2015 05:03:13 +0000</pubDate>
      <dc:creator>joebataz</dc:creator>
      <guid isPermaLink="false">11627@/two/discussions</guid>
      <description><![CDATA[<p>Have some APA104 LED strips and have a dozen or so custom palettes/chasers controlled from 12 potentiometers. Wanted to control the 2560 with DMX but after quite a bit of time wasted trying to get DMX in Serial data out and getting lots of speculation but no real WORKING examples I have decided to can DMX and just use a simple Processing GUI to do what I need. Any hints or code someone can point me to? Don't need a lot just a place to start from.</p>

<p>Thanks in advance for any help!!</p>

<p>Joe B</p>
]]></description>
   </item>
   <item>
      <title>How to display several curves using Arduino and a DHT11 sensor ?</title>
      <link>https://forum.processing.org/two/discussion/11506/how-to-display-several-curves-using-arduino-and-a-dht11-sensor</link>
      <pubDate>Tue, 30 Jun 2015 00:33:35 +0000</pubDate>
      <dc:creator>BigMacTheory</dc:creator>
      <guid isPermaLink="false">11506@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>I am a newbie using Processing and I would like to know how to draw several curves in one graph. 
It should not be too complicated, but the main thing is that I am using Arduino and a DHT11 sensor which monitors humidity and temperature with one digital output. What I would like to achieve is to monitor the values of humidity and temperature on Processing in one graph.</p>

<p>Here is the Arduino program :</p>

<pre><code>#include "DHT.h"
#define DHTPIN 2     // what pin we're connected to
#define DHTTYPE DHT11  

// Initialize DHT sensor for normal 16mhz Arduino
DHT dht(DHTPIN, DHTTYPE);

void setup() {

  Serial.begin(9600); 
  dht.begin();
 }

void loop() {

  int h = dht.readHumidity();
  // Read temperature as Celsius
  float t = dht.readTemperature();
  // Read temperature as Fahrenheit
  float f = dht.readTemperature(true);

  // Check if any reads failed and exit early (to try again).
  if (isnan(h) || isnan(t) || isnan(f)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
    }

  // Compute heat index
  // Must send in temp in Fahrenheit!
  float hi = dht.computeHeatIndex(f, h);

  //Serial.print("Humidity: "); 
  Serial.println(h);
  //Serial.print("Temperature: "); 
  Serial.print(t);
  delay(500);                        // wait 100ms for next reading


  }
</code></pre>

<p>And here is the Processing program I found on the Internet :</p>

<pre><code>import processing.serial.*;

Serial myPort;        // The serial port
int xPos = 1;         // horizontal position of the graph 

//Variables to draw a continuous line.
int lastxPos=1;
int lastheight=0;
float val;

void setup () {
  // set the window size:
  size(800, 600);        

  // List all the available serial ports
  println(Serial.list());
  // Check the listed serial ports in your machine
  // and use the correct index number in Serial.list()[].

  myPort = new Serial(this, Serial.list()[0], 9600);  //

  // A serialEvent() is generated when a newline character is received :
  //myPort.bufferUntil('\n');
  background(0);      // set inital background:
}
void draw () {
  if ( myPort.available() &gt; 0) {  // If data is available,
    val = myPort.read();          // read it and store it in val
    // Convert the values to set the radius

  }
  // everything happens in the serialEvent()
}

void serialEvent (Serial myPort) {
  // get the ASCII string:
  String inString = myPort.readStringUntil('\n');
  if (inString != null) {
    inString = trim(inString);                // trim off whitespaces.
    float inByte = float(inString);           // convert to a number.
    inByte = map(inByte, 0, 100, 0, height); //map to the screen height.

    //Drawing a line from Last inByte to the new one.
    stroke(127,34,255);     //stroke color
    strokeWeight(2);        //stroke wider
    line(lastxPos, lastheight, xPos, height - inByte); 
    lastxPos= xPos;
    lastheight= int(height-inByte);

    // at the edge of the window, go back to the beginning:
    if (xPos &gt;= width) {
      xPos = 0;
      lastxPos= 0;
      background(0);  //Clear the screen.
    } 
    else {
      // increment the horizontal position:
      xPos++;
    }
  }
}
</code></pre>

<p>I have the feeling it should be somewhere near this line <code>String inString = myPort.readStringUntil('\n');</code> but I have no idea how to extract both the temperature and moisture ; it does work with the temperature or the humidity depending on which but I don't know how to do with both.</p>

<p>Could you help me ?</p>

<p>Thanks,</p>
]]></description>
   </item>
   <item>
      <title>null pointer exception in a processing code.</title>
      <link>https://forum.processing.org/two/discussion/11024/null-pointer-exception-in-a-processing-code</link>
      <pubDate>Wed, 27 May 2015 02:42:28 +0000</pubDate>
      <dc:creator>JonathanVazquez06</dc:creator>
      <guid isPermaLink="false">11024@/two/discussions</guid>
      <description><![CDATA[<p>I have a problem with the code in the "process"</p>

<p>I'm using a controlled by a remote control receiver infrared sensor.
The data received by the Arduino sends me to successfully process, but does not allow me to compare the variable "val" with some code that you know it will allow me to continue with the program.</p>

<p>The function is:</p>

<p>Pressing a button, for example (game = 4C73914C) a specific text should appear.</p>

<p>And so on.</p>

<p>And I make that mistake when I make that comparison.</p>

<p>Codigo arduino.</p>

<pre lang="javascript">

#include 
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
decode_results results;

void setup(){
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver

  while(!Serial){
   ; 
  }
  
  pinMode(11, INPUT);
  establishContact();
}

void loop() {
  if (irrecv.decode(&amp;results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }
}

void establishContact() {
  while (Serial.available() </pre>

<p>import processing.serial.*;
Serial port; //Nombre del puerto serie
String val;
String val1;</p>

<p>boolean status = false;</p>

<p>void setup()
{
  size(640, 480); //Creamos una ventana de 800 píxeles de anchura por 600 píxeles de altura 
  println(Serial.list()); //Visualiza los puertos serie disponibles en la consola de abajo
  port = new Serial(this, Serial.list()[1], 9600); //Abre el puerto serie COM3</p>

<p>}</p>

<p>void draw()
{
}</p>

<p>void serialEvent( Serial myPort) {
//put the incoming data into a String - 
//the '\n' is our end delimiter indicating the end of a complete packet
val = myPort.readStringUntil('\n');
//make sure our data isn't empty before continuing
if (val != null) {
  //trim whitespace and formatting characters (like carriage return)
val1 = trim(val);
control();
}
}</p>

<p>void control(){
  if (val1.equals("4C73914C")== true){
     background(255,0,0);
     println ("EJERCICIO1", val1);
     status=!status; //El estado del color cambia
     port.write("A"); //Envia una "A" para que el Arduino encienda el led
  }
 else if(val1.equals("57564EEC") || val1.equals("D54CF430")){
 status =status ;
 port.write("B");
 }
 if(val1.equals("57564EEC")){
   background(0,255,0);
   println("EjJERCICIO2", val1);
   status = !status;
   port.write("C");
 }
 else if(val1.equals("4C73914C") || val1.equals("D54CF430")){
 status =status ;
 port.write("D");
 }</p>

<p>if(val1.equals("D54CF430")){
   background(255,255,0);
   println("EjJERCICIO3", val1);
   status = !status;
   port.write("E");
 }
 else if(val1.equals("4C73914C") || val1.equals("57564EEC")){
 status =status ;
 port.write("F");
 }</p>

<p>if(val1.equals("44C73928")){
   println("Salida");
   status = status;
   port.write("B");
   port.write("D");
   port.write("F");
   exit();<br />
 }</p>

<p>if(val1.equals("9AD2DF84")){
 println("Regresar");
 }
}
&lt;/pre</p>
]]></description>
   </item>
   </channel>
</rss>