Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Update</strong>: My suggestion is to first try communicating the Arduino with Processing by youself. This is what I describe below. If you want to jump straight to controlling the Arduino directly with Processing, the link provided by Binary Nerd is your best choice to get you started.</p> <p><strong>Update 2</strong>: Try this link as well: <a href="http://processing.org/discourse/yabb2/YaBB.pl?num=1191468953" rel="nofollow noreferrer">Netbeans and Processing</a></p> <hr> <p>Arduino code runs on the Arduino, and Processing code runs on your computer. If you want to control your Arduino through Processing, you will most likely use the serial port, and create two programs. One, on the Arduino, might receive commands and perform actions (turn LEDs on or off), or send back answers. The other, in Processing, might send the Arduino the necessary commands and process it's answers in some way.</p> <p>Here is a quick example I made for one LED and one analog input. This is untested code. Follow the steps. Once this has worked, you could try using Processing directly with the Arduino in Netbeans.</p> <p>Step 1. <strong>Arduino</strong></p> <ol> <li>Buy an Arduino board.</li> <li>Download the Arduino IDE (<a href="http://www.arduino.cc" rel="nofollow noreferrer">http://www.arduino.cc</a>)</li> <li>Connect the Arduino to you computer.</li> <li>Copy the Arduino code (below) into the Aruino IDE.</li> <li>Upload to the Arduino.</li> </ol> <p>Step 2. <strong>Processing</strong></p> <ol> <li>Download the Processing IDE.</li> <li>Copy the Processing code (below) into the Processing IDE.</li> <li>Make sure the COM port in the code is the one the Arduino is connected to.</li> <li>Run the Processing code.</li> </ol> <p>Arduino code:</p> <pre><code>int ledPin = 13; int analogPin = 0; char c = 0; void setup() { pinMode( ledPin, OUTPUT ); Serial.begin( 9600 ); } void loop() { // Wait for a character to arrive at the serial port. if( Serial.available() &gt; 0 ) { // Read one byte (character). c = Serial.read(); switch( c ) { case '1': // Turn LED on. digitalWrite( ledPin, HIGH ); break; case '0': // Turn LED off. digitalWrite( ledPin, LOW ); break; case 'q': case 'Q': // Send the reading from the analog pin throught the serial port. Serial.println( analogRead( analogPin ) ); break; } } } </code></pre> <p>Processing code (runs on your computer).</p> <pre><code>import processing.serial.*; Serial serial; String str; void setup() { size(400, 400); serial = new Serial(this, "COM1", 9600); // Use the serial port connected // to your Arduino. while( true ) { serial.write( '1' ); // Turn LED on. delay( 1000 ); // Wait one second serial.write( '0' ); // Turn LED off. delay( 1000 ); serial.write( 'Q' ); // Get analog reading serial.bufferUntil( 10 ); // Wait for the data from the Arduino. // This captures characters until a newline // is received, the runs serialEvent()... } } void draw() { background(0); } void serialEvent(Serial s) { println( s.readString() ); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload