In this project, we were asked to create a physical object that moves and has a ThingMark on it that allows the user to view an augmented reality experience using Vuforia. In addition to using the servo, we were asked to incorporate 1 sensor into our design.
We decided to create a box that would close itself depending on the light in the environment. Other than the servo sensor, we made use of the light sensor. The light sensor detects the light and the servo starts to function accordingly, so that the lid of the box would close with the help of a string that connects to the servo. We added some humor into the design and the AR experience to create a playful effect. Users are discouraged to open the box as it says "Do not open" in the AR, in a 3D label format, and when the box is opened, as servo starts working and pulling the string, the lid comes down and the box closes, while the text changes into "I told you not to open." Also, we inserted a funny cat image inside of the box as part of the design.
We first created a simple box with finger joints, using MakerCase. Then, we used Adobe Illustrator to work on the mechanism of the lid and created round holes on the sides that would connect with the top. In order to hide the Arduino board, we duplicated the top and created a middle layer inside, so that the board would go to the bottom of the box and the middle layer would be placed on top, covering it. We added two holes on the middle layer for the cables of the sensors to come out and then cut rectangular holes on the sides for the finger joints of the middle layer. We further added the image of our ThingMark ( 3000-15) at the top and inserted the cat image on the middle layer, which is observed when the box is opened.
Download clicking on the link
On Arduino, we first established a connection with servo and created servo object to control a servo. We defined the variables that will be used throughout the code.
Then, under void.setup(), we specified that servo is attached to the pin 0 and set it to initial position, the starting point. using myservo.write.
Moving on to the light sensor, we first created a variable, float, to store the value coming from the sensor at set it to analogRead(LIGHT), to read the light level from the sensor. Then, in order for the box to close, after a defined time, as the light sensor detects light, we used if-else statements.
In the first statement, the timer starts as the box is open and light comes in, light_value> 50, there is enough light. When the box is in the "closed" state, the timer resets.
In the following if statements, when the box is open, the lid closes after 2 seconds, and then the value of the text changes into "What did I tell you???", which is equal to ar_text_state =1. This is defined on the code below. When ar_text_state is equal to 0, meaning it is in the initial state, reset timer starts. After 3o seconds as the box remains in the closed state, the text goes back to "Don't open me!"
In order to connect to SystemLink and then LabVIEW to change the text, we used PUT_SystemLink function and defined relevant variables.
In the if-else statement, when in initial state (0), the text reads "Don't open me" as the box is closed. Else if, when the box is open in another scenario, the text switches into "What did I tel you???" and else, there is not text displayed.
As the servo starts to work depending on the light sensor, when the user opens the box, the lid closes with the help of the servo, as it pulls the string while moving 180 degrees. After the box is closed, the servo resets and stops working.
Click to access the VI
This part of the project was perhaps the most challenging part because it involved linking three different platforms together.
To begin with, on LabVIEW, we created a VI that includes ThingWorx Read (not actually necessary) and ThingWorx Write functions, along with SystemLink Read, since Arduino connects to SystemLink, SystemLink connects to LabVIEW eventually connects to Vuforia, to make our text value change as the box is opened.
After creating a control for ThingWorx Write, we created a Property titled BenMina_s1, of type String, as part of ME_Thing1 on the front panel. We also created a contol for the SystemLink Read function and linked our tag.
In order to run the code continuously and make the value of the text change automatically, we included a while loop on the diagram.
On Vuforia we created and used the ThingMark 3000:15 on the Canvas. Then we added a 3D Label on top of it and arranged the position and size accordingly. Since we wanted the text to change, we had to establish a connection with LabVIEW.
We added External Data under Services, chose ME_Thing1 and then set GetPropertyValues to connect to LabVIEW data and our property with Vuforia. We integrated BenMina_s1 property with the 3D label text