So I had to download the Library for Processing as this is the first time Im using arduino on my laptop (usually do this at uni). and ive gone through all of the steps that arduino actually give us and put what it told me on lines 1 ,2 ,4 also 1, 2 are needed for my criteria for my assignment but it's telling me that ''It looks like you're mixing ''active'' and ''static'' modes.
please help! ive never needed to use PrintIn(Arduino.List()); in the minimal amount of time ive done this but i was just going by what the website said.
1 import processing.serial.;
2 import cc.arduino.;
3 Arduino arduino;
4 printIn(Arduino.List()); //needed this to make it work on laptop
5
6
7 int downPin = 8;
8 int knobPin = 0;
9 float angle = -PI/4;
10 PVector location = new PVector(50, 300);
11 boolean shot = false;
12
13
14
15 CannonBall ball;
16
17 void setup() {
18 size(640, 360);
19 ball = new CannonBall(location.x, location.y);
20
21 arduino = new Arduino(this, Arduino.list()[4], 57600);
22 arduino.pinMode(downPin, Arduino.INPUT);
23 arduino.pinMode(knobPin, Arduino.INPUT);
24 }
25
26 void draw() {
27 background(255);
28 noStroke();
29 fill(100, 100, 100, 80);
30
31 int knobVal= arduino.analogRead(knobPin);//
32 int keypressed= arduino.digitalRead(downPin);//
33
34 //calculate the angle of the cannon based on mouseY position
35 angle= map(knobPin, 0, knobVal, -PI/2, PI/2);
36
37 pushMatrix();
38 translate(location.x, location.y);
39 rotate(angle);
40 rect(0, -5, 50, 10);//draw the cannon
41 popMatrix();
42
43 if (shot) {
44 PVector gravity = new PVector(0, 0.2);
45 ball.applyForce(gravity);
46 ball.update();
47 }
48 ball.display();
49
50 if (ball.location.y > height) {
51 ball = new CannonBall(location.x, location.y);
52 shot = false;
53 }
54
55 //when the mouse is pressed
56 if (mousePressed && shot== false) {
57 shot = true;
58 PVector force = PVector.fromAngle(angle);
59 force.mult(10);
60 ball.applyForce(force);
61 }
62 }
i am extremley new to this and hate programming so I dont particularly know what im going
im sorry about not having the numbered lines i tried to re add them myself the long way but i couldnt seem to add the numbers automatically because im a moron this isnt my forte
Well, when I copy the "code" you posted into Processing, and try to compile it, I get:
processing.app.SketchException: unexpected token: 1
at processing.mode.java.JavaBuild.preprocess(JavaBuild.java:326)
at processing.mode.java.JavaBuild.preprocess(JavaBuild.java:197)
at processing.mode.java.JavaBuild.build(JavaBuild.java:156)
at processing.mode.java.JavaBuild.build(JavaBuild.java:135)
at processing.mode.java.JavaMode.handleRun(JavaMode.java:176)
at processing.mode.java.JavaEditor$20.run(JavaEditor.java:481)
at java.lang.Thread.run(Thread.java:662)
and the first line is highlighted.
So, clearly, the code you posted is NOT the code that you are using in Processing.