Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: Convert Processing code to Arduino??? on: November 15, 2012, 11:29:11 am
@AWOL I made that change but when I verify the code below I am now getting the following error: incompatible types in assignment of 'float*' to 'float [10]'

**@PaulS Sorry,I was not being greedy:) and well spotted, I did leave some remnants of Java behind:)...

Code:
int xspacing = 32;   // How far apart should each horizontal location be spaced
int w;              // Width of entire wave
float theta = 0.0;  // Start angle at 0
float dx;  // Value for incrementing X, a function of period and xspacing
//float[] yvalues;  // Using an array to store height values for the wave
float yvalues [10]; 

void setup() {
  w = 320;
  dx = 0.40212387;
  yvalues = new float[10];
  Serial.begin(9600);
}

void loop() {
  Generatewave();
}

void Generatewave() {
  // Increment theta (try different values for 'angular velocity' here
  theta += 0.002;
  // For every x value, calculate a y value with sine function
  float x = theta;
  for (int i = 0; i < yvalues.length; i++) {
    yvalues[i] = sin(x)*10.0;
    Serial.println(yvalues[i]);
    x+=dx;
  }
}
2  Using Arduino / Programming Questions / Convert Processing code to Arduino??? on: November 15, 2012, 09:41:53 am
Hi.

I want to convert the code (below) from Processing into Arduino but I am getting errors with the syntax, basically what I want to do is to get a vibration motor to start, reach maximum speed and slow down again in the shape of a curve. I have it working in processing (using the Arduino Lib) but I would like to have it working also in the Arduino IDE as I want to disconnect the arduino from the computer...any help will be appreciated ...thanks in advance...

Code:
int xspacing = 32;   // How far apart should each horizontal location be spaced
int w;              // Width of entire wave
float theta = 0.0;  // Start angle at 0
float dx;  // Value for incrementing X, a function of period and xspacing
float[] yvalues;  // Using an array to store height values for the wave

void setup() {
  w = 320;
  dx = 0.40212387;
  yvalues = new float[w/xspacing];

}

void loop() {
  background(0);
  Generatewave();
}

void Generatewave() {
  // Increment theta (try different values for 'angular velocity' here
  theta += 0.002;
  // For every x value, calculate a y value with sine function
  float x = theta;
  for (int i = 0; i < yvalues.length; i++) {
    yvalues[i] = sin(x)*10.0;
     println(yvalues[i]);
    x+=dx;
  }
}
3  Using Arduino / Project Guidance / Multiple Arduinos on: October 05, 2011, 04:19:33 pm
Hi.
I am working on a project that requires two arduinos (one local & one wireless), re software: I am using the standard firmata & processing
I have started by assessing whether this is possible or not by using the code below to turn an led on on each board.  The codes compiles without any errors nor do I get any errors at runtime, however, it just will not communicate with the two boards.  Has anyone attempted this before or would you have any advise for me..

Big Thanks,

Tactiledata

Code:
import processing.serial.*;

import cc.arduino.*;
Arduino ard1, ard2;

void setup() {
  size(470, 200);
 
  println(Arduino.list());
  ard1 = new Arduino(this, Arduino.list()[0], 57600);
  ard2 = new Arduino(this, Arduino.list()[2], 57600);
 
  for (int i = 0; i <= 13; i++)
    ard2.pinMode(i, Arduino.OUTPUT);
   
}

  for (int i = 0; i <= 13; i++)
   
    ard1.pinMode(i, Arduino.OUTPUT);
}

void draw() {
 
}

void keyPressed() {
 
  if (key == 'q') {
    ard1.digitalWrite(13, Arduino.HIGH);
  }
 
    if (key == 'a') {
    ard1.digitalWrite(13, Arduino.LOW);
  }
    if (key == 'w') {
    ard2.digitalWrite(13, Arduino.HIGH);
  }
 
    if (key == 's') {
    ard2.digitalWrite(13, Arduino.LOW);
  }
   
   
}
Pages: [1]