I have am gathering analog data with an Arduino Uno. Using Processing, I can only display one serial event at a time. I need it to store data continuously. How do I do that.
Here is my code:
import processing.serial.*; Serial myPort; String bits; PFont font;
void setup() { size(800,200); myPort = new Serial(this, "COM1", 9600); myPort.bufferUntil('\n'); font = loadFont("TimesNewRomanPSMT-12.vlw"); textFont(font); }
void draw() { //The serialEvent controls the display }
I want to see the values from the analog pin on the Arduino Uno printed out in Processing. It works fine in Arduino, but I can't even get a zero to pop up from processing (which seems to be the usual complaint), just an empty gray box.
Here is my Arduino Code:
#include <Boards.h> #include <Firmata.h>
const int voltPin = 0; float denominator; int resistor1 = 51000; //resistors from amp int resistor2 = 4300; int inputPin = A0;
void setup() { Serial.begin(9600); denominator = (float)resistor2 / (resistor1+resistor2); } void loop() { float analogvoltage; float voltagereading; float finalvoltage; analogvoltage= analogRead(A0); voltagereading=(analogvoltage/1024)*5; //percent of total bits used times voltage range finalvoltage=analogvoltage/denominator; //voltage adjusted for amp Serial.println(finalvoltage, 10); //returns value, to ten decimal places delay(10);
Then in Processing
import processing.serial.*; import cc.arduino.*;
Arduino arduino; int analogPin = 0; int value = 0;
void setup(){ arduino = new Arduino(this, Arduino.list()[0], 57600); }
void draw(){ value = arduino.analogRead(analogPin); println(value); delay(10); }