Windows에서 Arduino 명령을 통해 Python 스크립트를 실행할 수있는 방법이 있습니까?Windows에서 Arduino Uno를 통해 Python 스크립트를 실행하십시오.
1
A
답변
1
이 질문에 대한 답변을 모르겠지만 Vpyt 여보 라이브러리는 함께 멋진 프로젝트를 만들거나 예를 들어 아두 이노 또는
그래서 viceversa에에서 파이썬으로 다시 센서와 점점 데이터를 연결 :
int trigPin=13; //Sensor Trig pin connected to Arduino pin 13
int echoPin=11; //Sensor Echo pin connected to Arduino pin 11
float pingTime; //time for ping to travel from sensor to target and return
float targetDistance; //Distance to Target in inches
float speedOfSound=776.5; //Speed of sound in miles per hour when temp is 77 degrees.
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(trigPin, LOW); //Set trigger pin low
delayMicroseconds(2000); //Let signal settle
digitalWrite(trigPin, HIGH); //Set trigPin high
delayMicroseconds(15); //Delay in high state
digitalWrite(trigPin, LOW); //ping has now been sent
delayMicroseconds(10); //Delay in low state
pingTime = pulseIn(echoPin, HIGH); //pingTime is presented in microceconds
pingTime=pingTime/1000000; //convert pingTime to seconds by dividing by 1000000 (microseconds in a second)
pingTime=pingTime/3600; //convert pingtime to hourse by dividing by 3600 (seconds in an hour)
targetDistance= speedOfSound * pingTime; //This will be in miles, since speed of sound was miles per hour
targetDistance=targetDistance/2; //Remember ping travels to target and back from target, so you must divide by 2 for actual target distance.
targetDistance= targetDistance*63360; //Convert miles to inches by multipling by 63360 (inches per mile)
Serial.println(targetDistance);
delay(100); //delay tenth of a second to slow things down a little.
}
그리고 파이썬
import serial #Import Serial Library
from visual import * #Import all the vPython library
arduinoSerialData = serial.Serial('com11', 9600) #Create an object for the Serial port. Adjust 'com11' to whatever port your arduino is sending to.
measuringRod = cylinder(radius= .1, length=6, color=color.yellow, pos=(-3,-2,0))
lengthLabel = label(pos=(0,5,0), text='Target Distance is: ', box=false, height=30)
target=box(pos=(0,-.5,0), length=.2, width=3, height=3, color=color.green)
while (1==1): #Create a loop that continues to read and display the data
rate(20)#Tell vpython to run this loop 20 times a second
if (arduinoSerialData.inWaiting()>0): #Check to see if a data point is available on the serial port
myData = arduinoSerialData.readline() #Read the distance measure as a string
print myData #Print the measurement to confirm things are working
distance = float(myData) #convert reading to a floating point number
measuringRod.length=distance #Change the length of your measuring rod to your last measurement
target.pos=(-3+distance,-.5,0)
myLabel= 'Target Distance is: ' + myData #Create label by appending string myData to string
lengthLabel.text = myLabel #display updated myLabel on your graphic
이 의지에
초음파 센서 앞에서 들고있는 것을 나타내는 파이썬으로 그래픽을 만들고 실시간으로 움직이는 물체를 볼 수 있습니다.나는 코드 fr을 취했습니다. 톰이 웹 사이트 :
이것은 파이썬에 아두 이노를 연결하는 방법 정말 좋은 튜토리얼을 가지고! 그리고 매우 간단합니다
0
저는 Python을 지원하는 Arduino 라이브러리가 없을 것이라고 생각합니다. Python을 사용하여 Arduino를 프로그래밍하려는 경우 Python이 해석되고 Arduino에 Python 전체에 대한 메모리가 없으므로 당신이 당신이 여기에서 찾을 수 있습니다 대부분의 코드 파이썬에서 찾을 것입니다 코드에 너무 차이가 C에게 당신은 아두 이노 프로그래밍을 배울 필요가있는 코드입니다보십시오 https://www.arduino.cc/en/Reference/HomePage
그러나 이들은 관련 파이썬 모듈의 일부입니다 Arduino에서 Python을 실행하는 방법 : http://playground.arduino.cc/CommonTopics/PyMite
관련 문제
- 1. Windows에서 PHP로 python 스크립트를 실행하십시오.
- 2. 안드로이드 앱에 Arduino UNO를 연결하고 싶습니다.
- 3. Windows에서 'python'이없는 python 프로그램을 실행하십시오.
- 4. Arduino-uno를 사용하여 튜브 라이트 제어
- 5. parse.com 데이터베이스에 이더넷 실드가있는 Arduino Uno를 연결합니다.
- 6. webpy에서 python 스크립트를 실행하십시오.
- 7. vb.net에서 python 스크립트를 실행하십시오.
- 8. AutoIt에서 Python 스크립트를 실행하십시오.
- 9. CruiseControl.NET에서 python 스크립트를 실행하십시오.
- 10. 웹에서 Python 스크립트를 실행하십시오.
- 11. iOS 앱에서 python 스크립트를 실행하십시오.
- 12. Windows의 cmd에서 Python 스크립트를 실행하십시오.
- 13. 다른 디렉토리에서 (python) 스크립트를 실행하십시오.
- 14. OSX의 PackageMaker에서 Python 스크립트를 실행하십시오.
- 15. ASP.Net에서 원격 Python 스크립트를 실행하십시오.
- 16. Mac 터미널에서 Python 스크립트를 실행하십시오.
- 17. ios에서 간단한 python 스크립트를 실행하십시오.
- 18. 쉘을 통해 자바 스크립트를 실행하십시오
- 19. 스크립트를 통해 루비 파일을 실행하십시오.
- 20. 이클립스를 사용하여 Windows에서 .sh (linux에서) 스크립트를 실행하십시오.
- 21. C# : Windows에서 OSX의 bash 스크립트를 실행하십시오.
- 22. Python - 파일을 .exe로 드래그하여 스크립트를 실행하십시오.
- 23. Fritzing으로 Arduino 스케치를 실행하십시오.
- 24. Eagle PCB 디자이너를 사용하여 Arduino UNO를 만드는 방법은 무엇입니까?
- 25. Arduino Uno를 SKYNAV skm53 GPS 모듈과 연결시 컴파일 오류가
- 26. Python 스크립트를 닫은 후 즉시 다시 실행하십시오.
- 27. 파이썬에서 쉘 스크립트를 실행하십시오.
- 28. HTML 웹 페이지의 python 스크립트를 실행하십시오.
- 29. php wget 및 python 스크립트를 실행하십시오.
- 30. pyspark 설정을 사용하여 python 스크립트를 실행하십시오.