arduino pin communication
in
Integration and Hardware
•
1 years ago
hi-
i'm trying to get a 3d model to turn whenever the button is pushed (thus activating pin 1 on the arduino). i have the breadboard and arduino wired up exactly as shown in the pushbutton example in the "getting started with arduino" book (with the exception of the wire being in pin 1, not pin 7).
if i'm not mistaken, this is an issue with the code. here's what i have.
what do i need to fix?
thanks!
import cc.arduino.*;
import processing.serial.*;
import saito.objloader.*;
Arduino arduino;
OBJModel model ;
float rotX, rotY, model_scale;
void setup()
{
size(800, 600, P3D);
arduino = new Arduino(this, Arduino.list()[0], 57600);
arduino.pinMode(1, Arduino.INPUT);
frameRate(30);
model = new OBJModel(this, "skull_interactive_lowres.OBJ", "absolute", QUADS);
model.enableDebug();
model.scale(160);
model.translateToCenter();
}
void draw()
{
background(0);
stroke(1);
noStroke();
lights();
pushMatrix();
translate(width/2, height/2, 0);
rotateX(rotY);
rotateY(rotX);
model.draw();
popMatrix();
// checks to see whether there's any voltage applied to pin 1,
// if it's on the model rotates along the x axis
if (arduino.digitalRead(1) == Arduino.HIGH)
rotX += 0.1;
}
1