DIY

Globe synchronized with virtual globe on PC screen

Globe synchronized with virtual globe on the screen PC The idea of ​​this project is to rotate the globe installed on the table on a special stand, a virtual globe rotated on the monitor screen.
Let's see how this happens in a short video.

Such a function will be convenient, for example, in a geography lesson.
Tools and materials: -Arduino uno; -Resistor 1 kOhm; -Wire; -Rotary encoder; -LED ring Neopixel 24; -Globe;
-MDF 3mm;
-Laser cutter;
Step one: soldering
The master did not provide the scheme, but it is not very complicated. There are four pads on the non-pixel ring. Two sites – power supply, one data input, and one data output. It is necessary to solder the wires to the three pads besides the “data output”.
Power supply is connected to 5V Arduino. “Data input” to any digital contact through a resistor.
You also need to connect an encoder.
Globe synchronized with virtual globe on PC screen Globe synchronized with virtual globe on the screen PC Globe synchronized with virtual globe on PC screen Globe synchronized with virtual globe on the screen PC Step two: LED ring
Now you need the LEDs to light up sequentially when you turn the globe. This is achieved by turning the encoder. The globe needs to be fixed on the encoder handle, and the LED ring fits under the globe.
To work with the neopixel ring, the wizard installed the adafruit neopixel library in the Arduino IDE. There are several sample projects in this library, one of which he used to check if the connections are working.
The wizard then wrote a code that makes part of the ring light up depending on the rotation of the rotary encoder.

 signed char lastpos = 0; void loop () & # 123; encoder.tick (); signed char pos = encoder.getPosition (); if (pos! = lastpos) & # 123; lastpos = pos; Serial.println (pos); lightPos = pos; lights (); }} void lights () & # 123; strip.clear (); strip.fill (strip.Color (255,255,255,255), lightPos% 20, 10); if (lightPos% 20+ 10 & gt; 24) & # 123; strip.fill (strip.Color (255,255,255,255), 0, lightPos% 20 + 10 - 24); } strip.show (); }  

Globe synchronized with virtual globe on the screen PC  Globe synchronized with the virtual globe on the PC screen Globe synchronized with virtual globe on the screen PC Step three: base
The master cut the base on a laser cutter. It is made in the shape of a box. Inside is an arduino. An encoder is mounted in the center. Then the LED ring and the globe are laid.
Globe synchronized with virtual globe on the screen PC  Globe synchronized with the virtual globe on the PC screen Globe synchronized with virtual globe on the screen PC Step four: the Unity project *
* Unity is a cross-platform environment for developing computer games .
To connect the Arduino to Unity, the wizard used Ardity. Ardity is a Unity package that allows Unity to send and receive information from Arduino. HE designed a scene with a ground on a dynamic background. The virtual ground will be lit in the same way as the ground, depending on the system time.
Ardity receives information from the Arduino and sends it to the custom script. The script below gets information from Ardity and uses it to rotate the Earth in Unity.

 using System.Collections; using System.Collections.Generic; using UnityEngine; public class RotateEarth & # 58; MonoBehaviour & # 123; //public GameObject sun; int lastMsg = 0; //Start is called before the first frame update void Start () & # 123; } void OnMessageArrived (string msg) & # 123; if (float.Parse (msg) & lt; = lastMsg) & # 123; transform.Rotate (0, 0, 18); //sun.transform.Rotate(0, -18, 0); lastMsg = int.Parse (msg); } else if (float.Parse (msg) & gt; = lastMsg) & # 123; transform.Rotate (0, 0, -18); //sun.transform.Rotate(0, -18, 0); lastMsg = int.Parse (msg); } Debug.Log (& # 34; msg arrived & # 34;); } void OnConnectionEvent (bool success) & # 123; }}  

 Globe synchronized with virtual globe on PC screen Globe synchronized with virtual globe on the screen PC In the future, the wizard is going to make several improvements to this project.
In particular, this a way to connect the globe to an encoder. In the next version, he plans to use an axle in the globe, which will be held in place by bearings. He plans to use 2 bearings to keep the axle securely in place. Then a rotary encoder will be placed under this axis.
He also plans to make a new case using a 3D printer.
 Globe synchronized with virtual globe on PC screen

Source:

usamodelkina.ru

Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button