interfaccia tinkerkit

ciao, ho un arduino uno (rev3?),uso un pc con windows 7, stavo provando a eseguire il tutorial per realizzare un interfaccia grafica per il giroscopio tinkerkit: http://scuola.arduino.cc/it/content/realizziamo-uninterfaccia-grafica-modulo-giroscopio-tinkerkit
Ho scaricato lo sketch in fondo alla pagina, ma quando lo apro con Arduino 1.0 e lo verifico prima di caricarlo sulla scheda, mi da diversi errori : stray '#' in program e poi sotto scritti in arancione

GyroGUIfromArduino.pde:-1: error: stray '#' in program
GyroGUIfromArduino.cpp:80:9: error: invalid digit "8" in octal constant
GyroGUIfromArduino.pde:-1: error: stray '#' in program
GyroGUIfromArduino.pde:-1: error: stray '#' in program
GyroGUIfromArduino.pde:-1: error: variable or field 'serialEvent' declared void
GyroGUIfromArduino.pde:-1: error: expected )' before 'p' GyroGUIfromArduino.pde:-1: error: expected ',' or '...' before 'graphBuffer' GyroGUIfromArduino.pde:-1: error: 'import' does not name a type GyroGUIfromArduino.pde:-1: error: 'Serial' does not name a type GyroGUIfromArduino.pde:-1: error: 'null' was not declared in this scope GyroGUIfromArduino.pde:-1: error: expected unqualified-id before '[' token GyroGUIfromArduino.pde:-1: error: expected unqualified-id before '[' token GyroGUIfromArduino.cpp: In function 'void setup()': GyroGUIfromArduino.pde:-1: error: 'size' was not declared in this scope GyroGUIfromArduino.pde:-1: error: 'class HardwareSerial' has no member named 'list' GyroGUIfromArduino.pde:-1: error: 'myPort' was not declared in this scope GyroGUIfromArduino.pde:-1: error: expected type-specifier before 'Serial' GyroGUIfromArduino.pde:-1: error: expected ;' before 'Serial'
GyroGUIfromArduino.pde:-1: error: 'frameRate' was not declared in this scope
GyroGUIfromArduino.pde:-1: error: 'y_rateVideoBuffer' was not declared in this scope
GyroGUIfromArduino.pde:-1: error: 'width' was not declared in this scope
GyroGUIfromArduino.pde:-1: error: 'x_rateVideoBuffer' was not declared in this scope
GyroGUIfromArduino.pde:-1: error: 'PFont' was not declared in this scope
GyroGUIfromArduino.pde:-1: error: expected ;' before 'font' GyroGUIfromArduino.pde:-1: error: 'font' was not declared in this scope GyroGUIfromArduino.pde:-1: error: 'loadFont' was not declared in this scope GyroGUIfromArduino.pde:-1: error: 'textFont' was not declared in this scope GyroGUIfromArduino.pde:-1: error: 'smooth' was not declared in this scope GyroGUIfromArduino.cpp: In function 'void draw()': GyroGUIfromArduino.pde:-1: error: 'background' was not declared in this scope GyroGUIfromArduino.pde:-1: error: 'fill' was not declared in this scope GyroGUIfromArduino.pde:-1: error: 'stroke' was not declared in this scope GyroGUIfromArduino.pde:-1: error: 'width' was not declared in this scope GyroGUIfromArduino.pde:-1: error: 'height' was not declared in this scope GyroGUIfromArduino.pde:-1: error: 'ellipse' was not declared in this scope GyroGUIfromArduino.pde:-1: error: 'textSize' was not declared in this scope GyroGUIfromArduino.pde:-1: error: 'temp' was not declared in this scope GyroGUIfromArduino.pde:-1: error: 'text' was not declared in this scope GyroGUIfromArduino.pde:-1: error: 'C63906' was not declared in this scope GyroGUIfromArduino.pde:-1: error: 'strokeWeight' was not declared in this scope GyroGUIfromArduino.pde:-1: error: 'line' was not declared in this scope GyroGUIfromArduino.pde:-1: error: 'y_rateVideoBuffer' was not declared in this scope GyroGUIfromArduino.pde:-1: error: 'x_rateVideoBuffer' was not declared in this scope GyroGUIfromArduino.cpp: At global scope: GyroGUIfromArduino.pde:-1: error: variable or field 'serialEvent' declared void GyroGUIfromArduino.pde:-1: error: expected )' before 'p'

premetto che ho anche installato le librerie "Firmata" come diceva all'interno dello sketch,ma che le metta o no non cambia nulla.
ora io non voglio stressare nessuno per il niente ma se non riesco neanche a fare due prove con uno sckech gia compilato non sò propio come fare.
se ho omesso qualcosa di importante fatemelo sapere grazie

Ecco lo skech:
/* -------+ TinkerKit! Gyroscope Module T000062 Dashboard +-------

This processing sketch grab data from an analog 2-axis Gyroscope
connected to Arduino, plot the angular rate readings into a graph;
then transform them into an angular position (inclination) trought
integration over time, dislpaying them into gauges.

Look on the product page for the Gyroscope specifiations:
http://store.arduino.cc/ww/index.php?main_page=product_info&cPath=16&products_id=94

Connect the gyroscope with two Toolkit wires to the Tinkerkit!
sensor shield into I0 and I1.

Mount the shield over an Arduino board then upload on it the
"Standard Firmata" sketch, then you are ready to go.

Processing, in order to work with Firmata protocol requires that
there is a library installed on your environment. Find the library here:
http://www.arduino.cc/playground/Interfacing/Processing

created 17 Sept 2011
by Federico Vanzati

This example code is in the public domain.
*/

import processing.serial.*; // Enable processing to use the serial port

Serial myPort; // Create object from Serial class
String myString = null;
String[] temp;
int lf = 10;

// Timing variables
int refreshScreen = 0;

// Variables to transform data into physical measurement
int rollSpeed, rollAngle, pitchSpeed, pitchAngle;
int offsetX, offsetY;

// Variables for displayng data
int[] y_rateVideoBuffer, x_rateVideoBuffer;
String str_yAngle, str_yGyroRate, str_xAngle, str_xGyroRate;

void setup()
{
size(700, 440);

String portName = Serial.list()[0];
myPort = new Serial(this, portName, 57600);
// wait a little to give time to Arduino to be initialized
delay(500);

frameRate(30);

y_rateVideoBuffer = new int[width];
x_rateVideoBuffer = new int[width];

PFont font;
font = loadFont("Monospaced.bold-26.vlw");
textFont(font);

smooth(); // smoothed shapes looks better!
}

void draw() {
background(0);
fill(#088D9D);
stroke(255);

//NOTA: misure prese dal centro
ellipse(width-70, height-300, 120, 120); // the circles
ellipse(width-70, height-100, 120, 120); // -> our gauges!

// Strings composition
textSize(26);
text("[Y] GYRO_Y speed: "+temp[1]+"°/s", 10, 70);
text("[X] GYRO_X speed: "+temp[5]+"°/s", 10, 270);
text("Angle", (width-120), 70);
text("Angle", (width-120), 270);
text(temp[3]+"°", (width-120), (height-210));
text(temp[7]+"°", (width-120), (height-10) );
textSize(28);
fill(#C63906);
text("TinkerKit! 2-Axis Gyroscope [T000062]", 28, 28);
textSize(15);
text("Reset Arduino to calibrate and restart this GUI", 10, (height -5));

// Draw the gauges indicator. Will display the inclination
strokeWeight(3);
float gyroY_radians = radians(-rollAngle)-HALF_PI;
line( (width-70), (height-300), (width-70)+(60cos(gyroY_radians)), (height-300)+(60sin(gyroY_radians)) );

float gyroX_radians = radians(-pitchAngle)-PI;
line( (width-70), (height-100), (width-70)+(60cos(gyroX_radians)), (height-100)+(60sin(gyroX_radians)) );
strokeWeight(1);

// call the function that plot the angular velocities, with few screen settings
graphMeThis(rollSpeed, y_rateVideoBuffer, 140, 300, 140);
graphMeThis(pitchSpeed, x_rateVideoBuffer, 140, 100, 140);
}

void serialEvent(Serial p) {
myString = p.readStringUntil(lf);
if (myString != null) {
temp = myString.split(" |\t");
rollSpeed = parseInt(temp[1]);
rollAngle = parseInt(temp[3]);
pitchSpeed = parseInt(temp[5]);
pitchAngle = parseInt(temp[7]);

println(rollSpeed+" "+rollAngle+" "+pitchSpeed+" "+pitchAngle);
}
}

/*
This function plot data over screen in a xPos and yPos given position.
[ySpan] is expressed in pixel and indicates the heigth that you give to the graph
*/
void graphMeThis(float inData, int[] graphBuffer, int xPos, int yPos, int ySpan)
{
// For each frame the buffer that contains the older samples are shifted by one position
for (int i=0; i<(width-xPos)-1; i++)
graphBuffer = graphBuffer[i+1];

  • // Store the new entry data*
  • graphBuffer[(width-xPos)-1] = (int)map(inData, -3000, 3000, -ySpan/2, ySpan/2); //salvo il nuovo dato...che plotto alla fine del grafico*
  • stroke(#E2F520, 150);*
  • strokeWeight(2);*
  • // plot the graph that goes from right to left*
  • for (int x=(width-xPos); x>1; x--)*
  • line( x, (height-yPos)-graphBuffer[x-1], x+1, (height-yPos)-graphBuffer[x]);*
  • noStroke();*
  • strokeWeight(1);*
    }

Ho paura che quello non sia lo sketch di arduino, mai codice processing
comunque dai un occhiata qui, http://arduino.cc/forum/index.php/topic,76113.15.html ultimi 3 post.

ho cercato su google l'errore non ho fatto nulla di più

ciao

...infatti è il codice processing, pure con qualche errorino probabilmente di scrittura....

Mi sono accorto che quella lì non è la versione più aggiornata del codice. Dopo do un'occhiata al tutorial e correggo tutti i problemi.

Per il momento ti allego qui l'ultima versione dei due sketch.

PS: dal titolo non si capiva che avevi problemi con l'interfaccia in processing per il giroscopio. Se ti va modificalo

GyroGUIfromArduino.pde (4.58 KB)

TK_GyroAngle.ino (3.92 KB)

grazie ora faccio qualche prova.

ok ho provato il link che mi hai postato:quello per processing ora mi funziona, quello per arduino il serial monitor funziona e vedo i cambiamenti nei valori solo che collegando un servo all o2 del tinker, il servo rogna ma non si muove.. :frowning: