Introduction: Creating a Virtual World Using Arduino and Python
Introduction to Our Project
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.
Step 1: Installation of All Software
Installation of Arduino IDE: You can download the latest Arduino IDE from this link:
Download and Install Python 2.7.8.for windows. Link is given below:
Download and Install Pyserial version 2.7 for windows. Link is given below:
Download and install the Vpython library for windows. Link is given below:
Step 2: Component Used
For this project you need :
2) Ultrasonic sensor
1) 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.
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.
Step 3: Circuit Description
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 above.
Here are the connections of our circuit:
Ultrasonic Sensor---Arduino UNO
Echo------------------- pin 11
Step 4: Code of the Project
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.
Step to run Code:
1) Firstly you can run Arduino code. The code is given below
2) After that You can run python script, before running python script you can install Pyserial and vPython. The python script is given below.
Congratulations you have successfully finished your project.
If have any doubt regarding this project feel free to comment us below or you can mail us on email@example.com
Thanks & Regards,
We have a be nice policy.
Please be positive and constructive.