Physical Computing 3/5

2.3: Physical Computing 3/5

During the Physical Computing Workshop part 3/5, we had to try out modules in small groups. I tested the Sparkfun Easy Driver + Stepper Motor and the MPR121 Capacitive Touch Sensor, both pretty enjoyable to play with — well, that’s it if you don’t mix-up the wires and smell the burn…

For the homework, I had to use something I didn’t get to try previously so I chose the Servo Motor. Setting it up was pretty easy following this tutorial, and the Servo Motor swept back and forth without any trouble.

I added a Potentiometer to control this Servo Motor, and it still works out pretty well. On top of that, I added a LED that is also controlled by the Potentiometer to make it fade. However, I feel that the input of the two components are having a face-to-face and somehow cancel the fade effect…? The Potentiometer still lights up the LED at the end of its turn though.

Before I reach out to a solution, here the code ↓↓↓

#include

Servo myservo;
const int potpin = 0;
int angle = 0;

const int ledPin = 10;
int brightness = 0;
int fade = 0;

void setup() {
myservo.attach(9);
pinMode(ledPin, OUTPUT);
}

void loop() {
angle = analogRead(potpin);
angle = map(angle, 0, 1023, 0, 180);
myservo.write(angle);

brightness = analogRead(potpin);
fade = map(brightness, 0, 1023, 0, 255);
analogWrite(ledPin, fade);
}

And the video ↓↓↓

On another note, this module seems pretty similar that of the Stepper Motor, but it is not as precise — the Stepper Motor is defined by steps and you can choose the angle of each step, while the Servo Motor turns around at once. Hence it seems to have less possibilities, but certainly I wasn’t able to make full use of it.

Leave a Reply

Your email address will not be published. Required fields are marked *