Ich frage mich, gibt es eine Möglichkeit, Python-Skript über Arduino-Befehle in Windows ausführen?Ausführen von Python-Skript über Arduino Uno in Windows
Antwort
Ich weiß nicht, ob das Ihre Frage beantwortet, aber Sie können Vpyt herunterladen hon Bibliothek ein paar coole Projekte mit ihm zu schaffen, oder Sensoren verbinden und Abrufen von Daten zurück in Python von Arduino oder viceversa
So zum Beispiel:
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.
}
Und in Python
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
Dieser Wille mache Grafiken in Python, die etwas darstellen, das du vor einem Ultraschallsensor hältst und du kannst das Objekt in Echtzeit bewegen sehen
Ich nahm den Code fr om diese Website:
Dies ist hat wirklich gutes Tutorial, wie Arduino anschließen Python! Und ist sehr einfach
Ich glaube, dass es keine Arduino-Bibliothek geben wird, die Python unterstützt, weil Python interpretiert wird und der Arduino nicht den gesamten Speicher von Python hat, wenn Sie ein Arduino dann mit Python programmieren möchten nur versuchen, C, um den Code, den Sie für die Programmierung des Arduino lernen müssen, ist nicht zu unterschiedlich zu dem Code, den Sie in python den meisten Code finden würde, finden Sie hier: https://www.arduino.cc/en/Reference/HomePage
aber diese sind einige der python-Modulen verwandten zum Ausführen von Python auf einem Arduino: http://playground.arduino.cc/CommonTopics/PyMite
- 1. Arduino Uno - Max Sensoren
- 2. ESP8266 und Arduino UNO
- 3. DHT11 + Arduino UNO + Himbeer pi3 + Windows Remote Arduino
- 4. Arduino Uno & NFC Shield
- 5. Arduino Uno R3 + SIM900
- 6. Arduino-Uno-Projekt
- 7. Arduino UNO Grundlagen für C#
- 8. Numerische Daten von Simulink zu Arduino Uno
- 9. Verbindung bmp280 zu arduino uno
- 10. pySerial schreibt in Arduino Uno wird gepuffert
- 11. Verfügt Arduino Uno/OSEPP Uno über genügend Speicher, um ein Servo-Array zu erstellen?
- 12. AVR Assembly auf Arduino Uno, Timer0 Konfiguration?
- 13. Arduino Uno + ESP8266 12E + Blynk + Relais
- 14. Leistungsüberwachung auf einem Dreiphasensystem mit Arduino Uno
- 15. Pars Arduino Uno Daten direkt zu IoT
- 16. Arduino Uno Wifi-Bibliothek funktioniert nicht
- 17. Arduino Uno als VGA zu HDMI Konverter
- 18. Arduino Uno wifi Mqtt Konnektor-Setup
- 19. Zeichen aus String entfernen C++/Arduino UNO
- 20. Welcher Arduino Uno Pin entspricht TCNT0?
- 21. Wie Beispielcode von ESP8266 zu Arduino Uno hochladen?
- 22. Wie kann man von einem Arduino Uno auf Nexmo zugreifen?
- 23. So senden Sie Daten von Arduino Uno an den PC über den USB-Anschluss
- 24. Ich versuche, Arduino UNO leuchten 4 Leds mit Cis-Code
- 25. Arduino Clone CH340G Fehler beim Kompilieren für Board Arduino/Genuino Uno
- 26. Ich möchte Arduino UNO mit einer Android App verbinden
- 27. Können wir Python auf Arduino ausführen?
- 28. Wie programmiere ich digitale Pins auf arduino uno?
- 29. Hat arduino uno Schutz gegen den USB-Port eines Computers?
- 30. Programmieren Sie ein Pic32mx250f128b mit Pic32prog auf einem Arduino Uno