Viewmaster Diorama

by letokeunen in Circuits > Arduino

146 Views, 0 Favorites, 0 Comments

Viewmaster Diorama

IMG_20210512_153650.jpg

Project overview

This guide enables you to create your own automated viewmaster with your own film using an Arduino and Processing.

The 'diorama'/ viewmaster will show you one of five photographs after ppushing the button. By pushing the button the disk will spin. Through the holes in between each picture the light sensor will detect light from the LED and will stop the motor and thus disk. This way you can see a different picture each time you press the button.

Don't forget to modify the ldrValue according to the light in the environment. You can test this feature and determine the values with the serial monitor on your computer.

Hardware

image00010.jpeg
viewmaster.jpg
image00007.jpeg

The Tinkercad circuit design and pictures show how I set up my hardware. You will see the folowing circuits: LED circuit, pushbutton circuit, light sensor circuit and finally the DC motor circuit. I used a small breadboard but I would recommend to use a bigger one so you have plenty of room in set up your circuits.

Software

x.JPG
y.JPG
z.JPG
zz.JPG
zzzzz.JPG
//setup pins motor
const int standBy = 10;

const int PWMA = 3;
const int AIN1 = 9;
const int AIN2 = 8;


//button
const int  buttonPin = 2;    // the pin that the pushbutton is attached to

// Variables will change:
int buttonPushCounter = 0;   // counter for the number of button presses
int buttonState = 0;         // current state of the button
int lastButtonState = 0;     // previous state of the button

//sensor
const int ldrPin = A0;
int ldrValue;

//led
const int ledPin = 11;

void setup() {
  pinMode(standBy, OUTPUT);

  pinMode(buttonPin, INPUT);
 
  //motor A
  pinMode(PWMA, OUTPUT);
  pinMode(AIN1, OUTPUT);
  pinMode(AIN2, OUTPUT);

  Serial.begin(9600);
}

void loop() {
  //led
  digitalWrite(ledPin, HIGH);

  buttonState = digitalRead(buttonPin);
  ldrValue = analogRead(ldrPin);
  Serial.print("ldrvalue1 = ");
  Serial.println(ldrValue);

  // compare the buttonState to its previous state
  if (buttonState != lastButtonState) {
    // if the state has changed, increment the counter
    if (buttonState == HIGH) {
      // if the current state is HIGH then the button went from off to on:
      //derest van de code
      Serial.println("button pressed");

      forward(50);
      delay(1000);

      while (ldrValue < 450) {
        Serial.println("while loop");
        ldrValue = analogRead(ldrPin);
        Serial.print("ldrvalue2 = ");
        Serial.println(ldrValue);
        forward(100);
        delay(10);
      }
      Serial.println("stop");
      stop();

    }
    // Delay a little bit to avoid bouncing
    delay(50);
  }
  // save the current state as the last state, for next time through the loop
  lastButtonState = buttonState;
 
}

void forward(int spd) {
  runMotor(spd, 0);
}

void back(int spd) {
  runMotor(spd, 1);
}

void runMotor(int spd, int dir) {
  digitalWrite(standBy, HIGH);

  boolean dirPin1 = LOW;
  boolean dirPin2 = HIGH;

  if (dir == 1) {
    dirPin1 = HIGH;
    dirPin2 = LOW;
  }

  digitalWrite(AIN1, dirPin1);
  digitalWrite(AIN2, dirPin2);
  analogWrite(PWMA, spd);

}

void stop() {
  digitalWrite(standBy, LOW);
}

Creating the Viewmaster

IMG_20210512_153631.jpg
IMG_20210512_153638.jpg
IMG_20210512_153749.jpg
IMG_20210512_153623.jpg

First I made a disk on which I placed five photographs. Then I cut a whole right across the picture on the disk. This way the picture will stop at the top. Next I carefully connected the motor to the center of the disk so the disk would turn evenly. After this I made a disk holder and a box to keep extra light from effecting the light sensor. Be sure to check your ldrValue according to the light in the environment! Finally I cut a whole to be able to press the button.

End Result

1.jpg
2.jpg
3.jpg
Viewmaster Diorama

Enjoy :)