Week 4: Leave Me Alone Box – Dom and Toby

This week we have been busy creating a sketch model of our box. We successfully setup and coded a servo so that it can open the lid of the box when the potentiometer is turned. The potentiometer allows the box lid to be raised different heights, but we will replace the potentiometer with code in our final model so that the only input is the switch.

This is the code we used:

#include <Servo.h>
Servo myservo;
int potpin = 0;
int val;
void setup()
void loop()
val = analogRead(potpin);

val = map(val, 0, 1023, 0, 100);



This is the setup we used:


This is a YouTube video of it working:


Leave a Reply

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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s