What port name do I use?

edited October 2016 in Arduino

I have got his code of someone else as i am a beginner. I am using a windows computer. I not sure what the port name is. This is the line of my code that isn't working. ** arduino = new Arduino(this, "/dev/com5", 57600. Line 34 is the one i need help with.

import cc.arduino.*;
import org.firmata.*;

import ddf.minim.*;  
import ddf.minim.analysis.*;
import processing.serial.*;
import cc.arduino.*;

Arduino arduino;

Minim minim;  
AudioPlayer song;
FFT fft;

int redPin1 = 12;
int greenPin1 = 11;
int bluePin1 = 10;

int redPin2 = 9;
int greenPin2 = 7;
int bluePin2 = 8;

int redPin3 = 6;
int greenPin3 = 4;
int bluePin3 = 5;

int color_id = 0;

int common_cathode = 0;

void setup() {
    size(800, 600);

    arduino = new Arduino(this, "/dev/com5", 57600);
    for (int i = 0; i <= 13; i++) arduino.pinMode(i, Arduino.OUTPUT);
    for (int i = 0; i <= 13; i++) arduino.digitalWrite(i,arduino.HIGH);

    minim = new Minim(this);  
    song = minim.loadFile("fugly.mp3");
    song.play();
    fft = new FFT(song.bufferSize(), song.sampleRate());    
}

void draw() {    
    background(#151515);

    fft.forward(song.mix);

    strokeWeight(1.3);
    stroke(#FFF700);

    // frequency
    pushMatrix();
      translate(250, 0);   
      for(int i = 0; i < 0+fft.specSize(); i++) {
        line(i, height*4/5, i, height*4/5 - fft.getBand(i)*4); 
        if(i%100==0) text(fft.getBand(i), i, height*4/5+20);
        if(i==200) {
          if(fft.getBand(i)>2) {
            setColor1(255,255,0);
            setColor3(255,255,0);
          }
          else if(fft.getBand(i)>1) {
            setColor1(255,0,255);
            setColor3(255,0,255);
          } else {
            setColor1(255,255,255);
            setColor3(255,255,255);
          }
        }
        if(i==50) {
          if(fft.getBand(i)>5) {
            color_id = (color_id+1)%4;
          } else if(fft.getBand(i)>3) {
            if(color_id==0) setColor2(0,255,0);
            else if(color_id==1) setColor2(0,255,255);
            else if(color_id==2) setColor2(0,0,255);
            else setColor2(255,0,0);
          } 
          else {
            setColor2(255,255,255);
          }
        } 
      }  
    popMatrix();

    stroke(#FF0000);

    //waveform
    for(int i = 250; i < song.left.size() - 1; i++) {
      line(i, 50 + song.left.get(i)*50, i+1, 50 + song.left.get(i+1)*50);
      line(i, 150 + song.right.get(i)*50, i+1, 150 + song.right.get(i+1)*50);
      line(i, 250 + song.mix.get(i)*50, i+1, 250 + song.mix.get(i+1)*50);
    }

    noStroke();
    fill(#111111);
    rect(0, 0, 250, height);

    textSize(24);
    fill(#046700);
    text("left amplitude", 10, 50); 
    text("right amplitude", 10, 150); 
    text("mixed amplitude", 10, 250); 
    text("frequency", 10, height*4/5); 
}

void stop()
{
    for (int i = 0; i <= 13; i++) arduino.digitalWrite(i,arduino.HIGH);
    song.close();  
    minim.stop();
    super.stop();
}
void setColor1(int red, int green, int blue)
{
  if(common_cathode==1) {
    red = 255-red;
    green = 255-green;
    blue = 255-blue;
  }
  arduino.digitalWrite(redPin1, red);
  arduino.digitalWrite(greenPin1, green);
  arduino.digitalWrite(bluePin1, blue);  
}
void setColor2(int red, int green, int blue)
{
  if(common_cathode==1) {
    red = 255-red;
    green = 255-green;
    blue = 255-blue;
  }
  arduino.digitalWrite(redPin2, red);
  arduino.digitalWrite(greenPin2, green);
  arduino.digitalWrite(bluePin2, blue);  
}
void setColor3(int red, int green, int blue)
{
  if(common_cathode==1) {
    red = 255-red;
    green = 255-green;
    blue = 255-blue;
  }
  arduino.digitalWrite(redPin3, red);
  arduino.digitalWrite(greenPin3, green);
  arduino.digitalWrite(bluePin3, blue);  
}

Answers

  • Didn't you already ask this? Don't post multiple copies of the same question, it confuses people.

  • edited October 2016

    @Sean2 -- what happens -- do you get an error message?

    What are you expecting to happen instead?

    As @koogs mentioned earlier:

    A search of the forum presents example of how you could accomplish what you want. Check it out:

    https://forum.processing.org/two/search?Search=arduino

    Did you find a solution? Did you try it? What didn't work?


    @koogs -- yes, duplicate, but the previous post was a screenshot -- may have been confused about not just adding to that thread. I say delete that one and keep this one.

Sign In or Register to comment.