Wake Up

Arduino + Servo + Narrative

wake up from Ricardo Munoz on Vimeo.

This slideshow requires JavaScript.

Code:

#include <Servo.h>

Servo servo1;

int photocellPin = 0 ;
int servoPin=9 ;
int pos=0 ;

void setup()
{
Serial.begin(9600);
servo1.attach(9);
}

void loop()
{
Serial.print(“Cell=”);
Serial.println(analogRead(photocellPin));

pos = analogRead(photocellPin);
pos = constrain (pos, 0, 200);

int servoPos = map(pos, 0, 200, 170, 90);
//int servoDegree = map(servoPos, 200, 0, 170, 90);
servo1.write (servoPos);
Serial.print(“ServoPos = “);
Serial.println(servoPos);

delay(50);
}

Advertisements

Your thoughts

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s