After coming back to the Lab after some time away, I’ve found that I need to work on my own to produce a project; I had already considered ideas in the weeks prior to this so I had a good idea of what I wanted to achieve. I figured that I could create my own pinhole camera by using a button, an arduino board and a servo motor. My concept would be made in such a way that the servo would be attached to a piece of material that would cover the pinhole and, when activated, the servo would move the material and would allow light to pass through to expose the inside of the box to light.
In order to make this a reality, I need to code an arduino board to tell a servo motor to move 90 degress when a button is pressed, wait 30 seconds and then move back to its original state. This would allow for a 30 second exposure in the camera.
I have been using tinkercad to attempt to achieve this. After trying different attempts using the ‘block’ method of coding that is used in tinkercad, I could not get the servo to do what I wanted. In an attempt to fix this, I used youtube to find tutorials for circuit boards that achieve a similar outcome. The first tutorial I came to was one from a channel called Robojax (https://www.youtube.com/watch?v=7woqNH_qby4). This tutorial showed how to control the direction of the servo by using two separate buttons. Following the tutorial and the code was somewhat confusing, but I attempted to follow the best I could. Unfortunately, following the tutorial, I was unable to make the circuit work in tinkercad. Even when copying his code over from his website it did not seem to work.
The next day, I tried to find tutorials that used the block system that is used in tinkercad as it seemed to be better suited for my understanding. I found an official tinkercad tutorial that explained how to wire and code a button to turn on an LED. In the video the presenter explains that using a combination of button state read commands with an if/else command, you can tell the arduino to anticipate a button press and then execute a command based off that. The example in the video used an LED, however I was sure that I could transfer some of the points across to a servo motor.
Using the code that was explained in this video, I was able to substitute the LED for a servo motor by connecting the motor to the breadboard in the place of the LED and then adding a wire to the arduino from the servo. I then made adjustments to the code to add the servo in the place of the LED; instead of the if/else statement triggering the LED to change state, I substituted the servo motor to rotate 90 degrees. This meant that whenever the button was pressed, the servo would rotate as required. I also did the same for the else section, specifying that the servo should return to 0 degrees when there is no input received from the button. Finally, I added a 30 second delay to the if statement to prolong the time the servo is rotated at 90 degrees for. As previously specified, 30 seconds is a good amount of time for a pinhole camera to expose any paper that would be contained in the camera box.
The above image shows the layout for my arduino on tinkercad. This was inspired from the aforementioned video and uses the same layout. Next to the layout you can see the code for the arduino which shows the steps taken to check the button state, and the if/else statement that follows. The following is the code in text form taken directly from the tinkercad circuit:
#include <Servo.h>
int buttonState = 0;
Servo servo_13;
void setup()
{
pinMode(2, INPUT);
servo_13.attach(13);
}
void loop()
{
buttonState = digitalRead(2);
if (buttonState == HIGH) {
servo_13.write(90);
delay(30000); // Wait for 30000 millisecond(s)
} else {
servo_13.write(0);
}
}
As I don’t have access to a breadboard, I have been unable to produce a physical example of the circuit displayed above.
Unfortunately I have run out of time to continue the production of my pinhole camera. Should I have had more time to produce this project, I would have loved to continue my understanding of the laser cutting process to fabricate a housing for the circuit I have produced. I thoroughly enjoyed the laser cutting aspect of this module and would love the chance to continue making things through this fabrication method.