Angry Turtle

Description

This Lego turtle gets angry and vibrates whenever there is light on the light sensor. There is a DC motor inside the turtle. The motor has a piece of cork on it, so running the motor makes it vibrate. If the light sensor reading is over 500 (about 50%), then the turtle will pulse vibration for 0.2 seconds, then pause for 0.5 seconds. This makes it sound angry without being overwhelming. The speed of the motor is directly related to the light reading.

Materials

  • 1 cork
  • Legos
  • Masking tape
  • 1 Arduino
  • 1 DC motor
  • 1 red LED
  • 1 light sensor
  • 1 220 Ω resistor
  • 1 10 KΩ resistor
  • 1 1 KΩ resistor
  • wires
  • 1 diode
  • 1 battery pack
  • 2 AA batteries
  • 1 transistor

Image

Angry Turtle
int lightSensorPin = 0; // select the input pin for the light sensor
int motorPin = 9; // select the pin for the Motor
int val = 0; // variable to store the value coming from the sensor
void setup() {
Serial.begin(9600);
}
void loop() {
val = analogRead(lightSensorPin); // read the value from the sensor, between 0 - 1024
Serial.println(val);
if (val > 500) {
analogWrite(motorPin, val/4); // analogWrite can be between 0-255
delay(200);
}
analogWrite(motorPin, 0); // turn off
delay(500);

Leave a Reply