Block Dude

Objective: Create a circuit with a motor that reacts according to the distance or a gesture of the user.

The circuit I used to build this week consists of an Arduino Uno, one LED, one phototransistor.

Meet Block Dude. He is very lonely and constantly looking you, his friend. As you get closer to him (the phototransistor), he becomes alert and looks at you. He has a little blue led on his head that blinks when he is alert.

To code my Arduino, I imported the servo library and used the map function to adjust the range of the analog input to a range of 0 to 180. I used the delay() to create an effect where the face seems to look for you when you are away from the phototransistor. In reality, this is caused from the motor twitching, but I just slowed it down so the face appears to be searching.

#include <Servo.h>      // include the servo library
Servo servoMotor;       // creates an instance of the servo object to control a servo
int servoPin = 3;       // Control pin for servo motor
int led = 2;
void setup() {
  Serial.begin(9600);       // initialize serial communications
  servoMotor.attach(servoPin); // attaches the servo on pin 3 to the servo object
  pinMode(led, OUTPUT);
void loop()
  int analogValue = analogRead(A0); // read the analog input
  Serial.println(analogValue);      // print it
  // if your sensor's range is less than 0 to 1023, you'll need to
  // modify the map() function to use the values you discovered:
  int servoAngle = map(analogValue, 0, 180, 40, 480);
  // move the servo using the angle from the sensor:

  // blink led if it senses you
  if (analogValue <80)
    digitalWrite(led, LOW);
    digitalWrite(led, HIGH);

   // turn on led at all times
  digitalWrite(led, HIGH);

The most time-consuming part for me was the fabrication. I wanted to make it visually appealing and hide some of the wires.

I started by changing the type of lever that is screwed onto the motor. Then, I cut a 2 small pieces of cardboard and covered them with yellow tape. First, I experimented with placing the led light in-between the 2 pieces of cardboard but that proved to be too bulky. Next, I tried using the natural grooves of the cardboard to place the wires of the led lights.  This placement was more efficient since the head could not be perfectly flat. I fastened the head to the motor’s gear by wrapping thin metal wire through the grooves of the cardboard head. These wires were concealed by using more tape. 

Lastly, I drew on the face and he came alive! 

Leave a Reply

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

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