Running the Arduino through Python

Running the Python Code:

  1. Open Arduino-Servo.py
  2. On line 3 assign the usbport to be the port we found in step 3 of creating a servo circuit.
  3. Run the code in Python 2
  4. To move a servo: in the REPL type move(1, 80). This will call the move function. The 1 is the servo number as defined in the Arduino code (so the servo connected to port 2), the 80 is the angle we want the servo to move to.

This defines the process by which an Arduino can be given commands via Python. This process can be extended to allow Python to interact with a variety of sensors and actuators through the Arduino.

results matching ""

    No results matching ""