Skip to content →

p-comp / week 04

this week i took the time to review all the concepts we were taught during class. obviously the quizz was the kick start for that, but i’m glad it was because i really want to be comfortable with the electrical part of the circuit. i was also able to make all the labs and understand how the circuit and code are working together.

so for this assignment, i decided to work with servo motors to make a thread reel to move. if i had more time, i’d definitely try to make a structure so that you can let the thread roll around freely. i felt like it was much clear for me to build it by myself after i had reviewed all the content, so i was able to put the servo motors with a photocell. the software read the photocell values and mapped it, giving a correspondent value within angles (0-180).

and the code for this circuit:

Servo servoMotor1;
Servo servoMotor2;

int photoValue = 0;
int servoPin1 = 3;
int servoPin2 = 5;
int servoAngle = 0;
int libraryInstance = 0;

void setup() {

void loop() {
  int photoValue = analogRead(A0);
  int servoAngle = map(photoValue, 150, 980, 0, 180);
  servoMotor2.write(180 - servoAngle);


Published in fall 2015 p-comp


Leave a Reply

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