Menu Close
Spread the love

Visual python Arduino

 

Visual python Arduino nano analog potentiometer with vpython visual script

required python library :

  1. vpython library http://vpython.org/
  2. serial library https://pypi.python.org/pypi/pyserial/2.7
Visual python Arduino
DIAGRAM
#Python code:


from visual import *
import serial

usbSerial = serial.Serial('com3',9600)

mysene = display(title='Arduino Voltage')
mysene.width = 400
mysene.height = 400
mysene.autoscale=True
mysene.range= (12,12,12)

target = cone(pos=(0,0.1,0),radius=4 ,color=color.green)
 
while (1==1):
  rate(25)
  if(usbSerial.inWaiting()>0):
    myData = usbSerial.readline()
    value = float (myData)
    target.axis = 0,value,0
    volt=" V"
    text = label(pos=(0,7.5,0),border=10,line = True, text = str(myData + volt) )

 

 

uper

//ARDUINO CODE:
int pot = A0;//pot ist Analog pin 0
int readValue;// Declaring unser readvalue variable
float Voltage;
int led2= 3;
int Voltage2;
void setup() {
pinMode(pot,INPUT); //make pot as input
Serial.begin(9600); // Start your Serial Port
}
void loop() {
readValue= analogRead(pot);
delay(50);
Voltage = (5./1023.)*readValue + 0.01;
Voltage2 = readValue/4;
Serial.println(Voltage);
analogWrite(led2,Voltage2);

}

Down
Visual Arduino

 

For more Please make sure to subscribe to Officialhrm YouTube channel and like Facebook Page.

Thank you for visiting OfficialhrmPlease don’t forget to share this website with your friends.

Download

File Description Date added File size Downloads
zip arduino_analog August 15, 2018 4:26 pm 165 KB 8042
Posted in Arduino

Related Posts

Leave a Reply

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