Personal Project 3: Etch A Sketch
Etch-A-Sketch
I needed to make something with the arduino and something art related. So with two knobs and a screen to draw on I thought I could recreate the etch a sketch. The etch a sketch would fulfill the requirements and a fun little thing to make.
Initial Setups
This is the initial build I used for my testing to make sure that I can get different values for each potentiometer and a value from the tilt sensor. .
This was the code I used to get the initial reads and would make sure that I would be sending the proper data. I did come across an issue here with the mapping and have it solved later. My unity was a blank 2d core and I created a small square prefab.
This is my final setup and parts list. The values i got from the potentiometer were correct and the sensor would detect when tilted.
Final Coding
Arduino:
This was a total of 40 lines of code on the Arduino side. The delay is a little bit lower so that more will get drawn to the screen. I also had to do the map function calculation separately because the map had rounded the answers due to integer division and I needed precision so i change the variable type to float and got the values I wanted.
Unity:
The coding on the unity side was also pretty small. We do the normal data stream then we just take the values from the potentiometers each for a respective axis and create a square at those coordinates. Then when the tilt sensor is shaken it causes all the cubes to be deleted.
Final Thoughts
This was a fun project, and it is not the most fully polished the video may catch it but sometimes when the code starts the string will have the wrong format but if you click resume it runs perfectly fine. I believe it is due to the delay being so low, but I need it lower to have a steadier drawing. Also, sometimes when the deletion happens a cube gets stuck and not deleted.
Comments
Post a Comment