PFA:008 – Arduino + Processing

Servo Motors

In our example we controlled the servo motro with the potentiometer. You can also try to use the light sensor instead of the pot.

screen-shot-2016-10-23-at-22-19-06

#include <Servo.h>
Servo motor;
int pos = 0;
int potVal = 0;

void setup() {
  // put your setup code here, to run once:
  motor.attach(10);
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  potVal = analogRead(A0);
  //potVal will be between 0-1023
  //pos should be between 0-180
  pos = map(potVal,0,1023,0,180);
  Serial.println(pos);
  motor.write(pos);
}

Processing & Sound

Just like video, working with sound in Processing also requires an external library. You can try two different options:

  • The Processing Sound library
  • Minim library

Both can be installed with the Contribution Managager, but some people had problems getting the Sound library to run properly. (I will update here if I figure out where the issue is).