How to create a simple virtual world using vPython library. In this project we are using Arduino and Ultasonic Sensor for sensing the virtual world. The virtual world is use in real time based on measurements from the Arduino and ultrasonic sensor. In this project you can use how to combine Arduino, Python, and vPython library to create a virtual world, i.e. virtual object updated based on sensor measurements.
Installation of All SoftwareArduino IDE:
You can download the latest Arduino IDE from this link: https://www.arduino.cc/en/Main/Software
- Python: Download and Install Python 2.7.8.for windows. Link is given: https://www.python.org/downloads/windows/
- Pyserial: Download and Install Pyserial version 2.7 for windows. Link is given: https://learn.adafruit.com/arduino-lesson-17-email...
- vPython: Download and install the Vpython library for windows. Link is given: http://vpython.org/
For this project you need:
- Arduino
- Ultrasonic sensor
- Jumper wires
- Breadboard
Arduino UNO: Arduino/Genuino Uno is a microcontroller board based on the ATmega328P (datasheet). It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header and a reset button.
Ultrasonic sensor: This is the HC-SR04 ultrasonic ranging sensor. This economical sensor provides 2cm to 400cm of non-contact measurement functionality with a ranging accuracy that can reach up to 3mm. Each HC-SR04 module includes an ultrasonic transmitter, a receiver and a control circuit.
First we are going to connect ultrasonic sensor with Arduino board. Then according to program our ultrasonic sensor going to generate a trigger signal which is going to receive by our echo pin of Ultrasonic Sensor. Then we are going to run our Arduino code. According to Arduino code our Ultrasonic Sensor detect the distance of any object.
Circuit Diagram of this project is given below:
Here are the connections of our circuit:
Ultrasonic Sensor---Arduino UNO
- GND---------------------GND
- Echo------------------- pin 11
- Trig..........................pin 13
- Vcc.........................5v
In software part we run two code, first is Arduino code and other is Python script. Firstly we can run Arduino code, after that run Python script. According to Python script, you make any virtual object, with the help of virtual object ultrasonic sensor detect the distance like figure 1 and figure 2.
Steps to Run the Code:
- Firstly you can run the Arduino code. The code is given in link.
- After that you can run the python script. Before running Python script you can install Pyserial and vPython. The python script is given in link
Congratulations you have successfully finished your project.
If you have any doubts regarding, this project feel free to comment below or you can email us at info@deligence.com
Comments