Project tutorial
ARMin: Simple Robot Arm Controller Using Python

ARMin: Simple Robot Arm Controller Using Python © MIT

Control servos/motors connected to an Arduino robot arm kit using a Raspberry Pi, Python, and an Xbox 360 controller.

  • 1,246 views
  • 0 comments
  • 4 respects

Components and supplies

A000066 iso both
Arduino UNO & Genuino UNO
×1
Pi 3 02
Raspberry Pi 3 Model B
×1
Adeept Robot Arm Kit
×1
18650 li-ion battery
×2
xbox 360 controller
×1

Necessary tools and machines

Screwdriver

About this project

I wanted to do a straightforward Arduino robot controller using my old Xbox 360 controller connected to a Raspberry Pi. So I went ahead and found some old parts and cobbled things together.

Demo Video

Disclaimer: There are some projects already out there that utilize this approach, but I want to consolidate and share the steps as I go along my own little project.

System Overview

The project consists of the following:

  • Raspberry Pi
  • Arduino
  • Robot arm kit
  • Wireless Xbox 360 dongle
  • Xbox 360 controller

The servos of the robot arm kit are connected to the Arduino's GPIOs (pin 9, 6, 5, 3, 11) as detailed below.

The Arduino is connected to the Raspberry Pi through USB along with the wireless Xbox 360 dongle.

Setting up the robot arm kit

So I got this kit for cheap from warehouse deals on Amazon. I've been wanting to test out these since forever, so I snatched it up once something went on sale.

The kit comes with six servos but only uses five of them. The kit also has all the necessary tools for you to build it which is thoughtful. It includes a dual 18650 battery holder but doesn't come with the 18650 batteries. So I had to source them from an old laptop battery.

Building the kit is kinda straightforward. The instructions can be seen here: [http://www.adeept.com/learn/details/id/31]. I suggest screwing in the servo wings to the acrylic pieces first before outfitting the servo motor. This helps decrease the frustration of screwing things in. Another caveat is the base with the ball bearings was not flush when mounting. So I had to loosen the screw of the servo wing to hit the right distance without hindering movement of the base.

Setting up the Arduino

Open up your Arduino IDE and copy/paste the prototype.ino sketch. Upload the code to your Arduino and that's it!

Note: I only tried the code on an Arduino Uno. Other boards will be YMMV.

Setting up the Raspberry Pi

There are dozens of tutorials on setting up the Raspberry Pi, from OS mounting, updating and Python installation. These change as new versions pop up. So I suggest checking out the latest guides on the interwebz for these.

To start off, we'll be installing xboxdrv for the controller command recognition.

sudo apt-get install xboxdrv

After that, let's do a sanity check by running:

sudo xboxdrv --detach-kernel-driver

This will display outputs like this:

X1:  -284 Y1:  1708  X2:   664 Y2:  -515  du:0 dd:0 dl:0 dr:0  back:0 guide:0 start:0  TL:0 TR:0  A:0 B:0 X:0 Y:0  LB:0 RB:0  LT:  0 RT:  0
X1:   170 Y1:  1708  X2:   664 Y2:  -515  du:0 dd:0 dl:0 dr:0  back:0 guide:0 start:0  TL:0 TR:0  A:0 B:0 X:0 Y:0  LB:0 RB:0  LT:  0 RT:  0
X1:   511 Y1:  1708  X2:   664 Y2:  -515  du:0 dd:0 dl:0 dr:0  back:0 guide:0 start:0  TL:0 TR:0  A:0 B:0 X:0 Y:0  LB:0 RB:0  LT:  0 RT:  0
X1:  1193 Y1:  1377  X2:   664 Y2:  -515  du:0 dd:0 dl:0 dr:0  back:0 guide:0 start:0  TL:0 TR:0  A:0 B:0 X:0 Y:0  LB:0 RB:0  LT:  0 RT:  0

These are your controller commands. The numbers beside the letters should change as you press the different buttons or move around the joysticks. If it works, great! If not, double check xboxdrv installed properly. Also check the user permissions. Now get the python module from the repository using:

wget https://raw.githubusercontent.com/FRC4564/Xbox/master/xbox.py 

Next is to setup arduino-python3. The API requires several dependencies:

  • Python 3.7
  • pyserial 2.6 or higher

So let's install pyserial using this:

pip install pyserial

Now we can install arduino-python3, using the command:

pip install arduino-python3

Before we do anything else, time to do another sanity check. Create and run the blink.py. This can be found in mkals GitHub repository (https://github.com/mkals/Arduino-Python3-Command-API) which I also included on the "codes" section.

python blink.py

If it gives some permission issues, try running as sudo:

sudo python blink.py

This should trigger LED13 of your arduino to blink in 1 second intervals. If it doesn't work, try checking the following:

  • prototype.ino sketch is uploaded properly
  • BAUDRATE of your arduino
  • COMPORT is detected

Raise your arms!

Time to play with our robot arm! First, connect your Xbox 360 controller (wireless or wired). Then create and run the arduino-control.py. The robot arm should shoot straight up when turned on. Now fiddle around with the controller and watch your robot arm dance to your command!

The nitty-gritty

The claw (servo5) is controlled using the right trigger while the other servos are mapped to the analog sticks. The left analog stick controls the base (servo1) and the first joint (servo2). The right analog stick, on the other hand, controls servo 3 and 4 which is the second joint and wrist, respectively.

# Move servo with respect to the left analog stick X values limited to the min-max angle set 
def leftXmove(servonum,minAngle,maxAngle):
   angle = angle1
   if int(joy.leftX()) > 0:
       angle = angle - 2 
       if angle <= minAngle:
           angle = minAngle
       return angle
   elif int(joy.leftX()) < 0:
       angle = angle + 2
       if angle >= maxAngle:
           angle = maxAngle
       return angle
   else:
       return angle
  
# Move servo with respect to the left analog stick X values limited to the min-max angle set 
def leftYmove(servonum,minAngle,maxAngle):
   angle = angle2
   if int(joy.leftY()) > 0:
       angle = angle - 2
       if angle <= minAngle:
           angle = minAngle
       return angle
   elif int(joy.leftY()) < 0:
       angle = angle + 2
       if angle >- maxAngle:
           angle = maxAngle
       return angle
   else:
       return angle
  
# Move servo with respect to the right analog stick Y values limited to the min-max angle set     
def rightYmove(servonum,minAngle,maxAngle):
   angle = angle3
   if int(joy.rightY()) > 0:
       angle = angle - 2
       if angle <= minAngle:
           angle = minAngle
       return angle
   elif int(joy.rightY()) < 0:
       angle = angle + 2
       if angle >= maxAngle:
           angle = maxAngle
       return angle
   else:
       return angle
  
# Move servo with respect to the right analog stick X values limited to the min-max angle set     
def rightXmove(servonum,minAngle,maxAngle):
   angle = angle4
   if int(joy.rightX()) > 0:
       angle = angle - 2
       if angle <= minAngle:
           angle = minAngle
       return angle
   elif int(joy.rightX()) < 0:
       angle = angle + 2
       if angle >= maxAngle:
           angle = maxAngle
       return angle
   else:
       return angle
  
# Move servo when right trigger is used
def rightTrigmove(servonum,minAngle,maxAngle):
   angle5 = minAngle
   if int(joy.rightTrigger()) > 0:
       angle5 = maxAngle
       board.Servos.write(servonum,angle5)
   else:
       board.Servos.write(servonum,minAngle)

The other buttons on the controller can be mapped to another servo, LED, rubberband launcher, lasers, sensors, etc. But of course you need to code it in. For example, if you want an LED on pin 13 to light up when A is pressed:

board.pinMode(13, "OUTPUT")
  
if joy.A() == 1:
    board.digitalWrite(13, "HIGH")
else:
    board.digitalWrite(13, "LOW")

Play around, customize, and have fun with it!

Some useful references:

https://github.com/mkals/Arduino-Python3-Command-API

https://github.com/pyserial/pyserial

https://github.com/FRC4564/Xbox

Code

arduino-control.pyPython
This is the code to be run on your Raspberry Pi. Depending on what permission level you have, you can use -- sudo python arduino-control.py -- on the command line
#!/usr/bin/env python
from __future__ import print_function
import xbox
from Arduino import Arduino
import time

# Define Arduino variables
servo1 = 9
servo2 = 6
servo3 = 5
servo4 = 3
servo5 = 11

board = Arduino()
board.Servos.attach(servo1)
board.Servos.attach(servo2)
board.Servos.attach(servo3)
board.Servos.attach(servo4)
board.Servos.attach(servo5)

angle1 = 90
angle2 = 90
angle3 = 90
angle4 = 90
angle5 = 0

# Format floating point number to string format -x.xxx
def fmtFloat(n):
    return '{:6.3f}'.format(n)

# Print one or more values without a line feed
def show(*args):
    for arg in args:
        print(arg, end="")

# Print true or false value based on a boolean, without linefeed
def showIf(boolean, ifTrue, ifFalse=" "):
    if boolean:
        show(ifTrue)
    else:
        show(ifFalse)

# Move servo with respect to the left analog stick X values limited to the min-max angle set 
def leftXmove(servonum,minAngle,maxAngle):
    angle = angle1
    if int(joy.leftX()) > 0:
        angle = angle - 2 
        if angle <= minAngle:
            angle = minAngle
        return angle
    elif int(joy.leftX()) < 0:
        angle = angle + 2
        if angle >= maxAngle:
            angle = maxAngle
        return angle
    else:
        return angle
    
# Move servo with respect to the left analog stick X values limited to the min-max angle set 
def leftYmove(servonum,minAngle,maxAngle):
    angle = angle2
    if int(joy.leftY()) > 0:
        angle = angle - 2
        if angle <= minAngle:
            angle = minAngle
        return angle
    elif int(joy.leftY()) < 0:
        angle = angle + 2
        if angle >- maxAngle:
            angle = maxAngle
        return angle
    else:
        return angle

# Move servo with respect to the right analog stick Y values limited to the min-max angle set     
def rightYmove(servonum,minAngle,maxAngle):
    angle = angle3
    if int(joy.rightY()) > 0:
        angle = angle - 2
        if angle <= minAngle:
            angle = minAngle
        return angle
    elif int(joy.rightY()) < 0:
        angle = angle + 2
        if angle >= maxAngle:
            angle = maxAngle
        return angle
    else:
        return angle

	
# Move servo with respect to the right analog stick X values limited to the min-max angle set     
def rightXmove(servonum,minAngle,maxAngle):
    angle = angle4
    if int(joy.rightX()) > 0:
        angle = angle - 2
        if angle <= minAngle:
            angle = minAngle
        return angle
    elif int(joy.rightX()) < 0:
        angle = angle + 2
        if angle >= maxAngle:
            angle = maxAngle
        return angle
    else:
        return angle

# Move servo when right trigger is used
def rightTrigmove(servonum,minAngle,maxAngle):
    angle5 = minAngle
    if int(joy.rightTrigger()) > 0:
        angle5 = maxAngle
        board.Servos.write(servonum,angle5)
    else:
        board.Servos.write(servonum,minAngle)

# Instantiate the controller
joy = xbox.Joystick()

# Show various axis and button states until Back button is pressed
print("Xbox controller sample: Press Back button to exit")
while not joy.Back():
    # Show connection status
    show("Connected:")
    showIf(joy.connected(), "Y", "N")    
    # Left analog stick
    show("  Left X/Y:", fmtFloat(joy.leftX()), "/", fmtFloat(joy.leftY()))      
    # Right analog stick
    show("  Right X/Y:", fmtFloat(joy.rightX()), "/", fmtFloat(joy.rightY()))  
    # Right trigger
    show("  RightTrg:", fmtFloat(joy.rightTrigger()))
    # Poll controller leftX values and move servo1 accordingly
    angle1 = leftXmove(servo1,0,180)
    board.Servos.write(servo1,angle1)
    # Poll controller leftY values and move servo2 accordingly
    angle2 = leftYmove(servo2,0,120)
    board.Servos.write(servo2,angle2)
    # Poll controller rightY values and move servo3 accordingly
    angle3 = rightYmove(servo3,0,180)
    board.Servos.write(servo3,angle3)
    # Poll controller rightX values and move servo4 accordingly
    angle4 = rightXmove(servo4,0,180)
    board.Servos.write(servo4,angle4)
    # Move claw conencted to servo5 depending on right trigger value
    rightTrigmove(servo5,0,90)
    # A/B/X/Y buttons
    show("  Buttons:")
    showIf(joy.A(), "A")
    showIf(joy.B(), "B")
    showIf(joy.X(), "X")
    showIf(joy.Y(), "Y") 
    # Dpad U/D/L/R
    show("  Dpad:")
    showIf(joy.dpadUp(),    "U")
    showIf(joy.dpadDown(),  "D")
    showIf(joy.dpadLeft(),  "L")
    showIf(joy.dpadRight(), "R")  
    # Move cursor back to start of line
    show(chr(13))
# Close out when done
joy.close()
prototype.inoArduino
Upload this sketch to your Arduino
#include <SoftwareSerial.h>
#include <Wire.h>
#include <Servo.h>
#include <EEPROM.h>

void Version(){
  Serial.println(F("V0.6"));
}


SoftwareSerial *sserial = NULL;
Servo servos[8];
int servo_pins[] = {0, 0, 0, 0, 0, 0, 0, 0};
boolean connected = false;

int Str2int (String Str_value)
{
  char buffer[10]; //max length is three units
  Str_value.toCharArray(buffer, 10);
  int int_value = atoi(buffer);
  return int_value;
}

void split(String results[], int len, String input, char spChar) {
  String temp = input;
  for (int i=0; i<len; i++) {
    int idx = temp.indexOf(spChar);
    results[i] = temp.substring(0,idx);
    temp = temp.substring(idx+1);
  }
}

uint8_t readCapacitivePin(String data) {
  int pinToMeasure = Str2int(data);
  // readCapacitivePin
  //  Input: Arduino pin number
  //  Output: A number, from 0 to 17 expressing
  //  how much capacitance is on the pin
  //  When you touch the pin, or whatever you have
  //  attached to it, the number will get higher
  //  http://playground.arduino.cc/Code/CapacitiveSensor
  //
  // Variables used to translate from Arduino to AVR pin naming
  volatile uint8_t* port;
  volatile uint8_t* ddr;
  volatile uint8_t* pin;
  // Here we translate the input pin number from
  //  Arduino pin number to the AVR PORT, PIN, DDR,
  //  and which bit of those registers we care about.
  byte bitmask;
  port = portOutputRegister(digitalPinToPort(pinToMeasure));
  ddr = portModeRegister(digitalPinToPort(pinToMeasure));
  bitmask = digitalPinToBitMask(pinToMeasure);
  pin = portInputRegister(digitalPinToPort(pinToMeasure));
  // Discharge the pin first by setting it low and output
  *port &= ~(bitmask);
  *ddr  |= bitmask;
  delay(1);
  // Make the pin an input with the internal pull-up on
  *ddr &= ~(bitmask);
  *port |= bitmask;

  // Now see how long the pin to get pulled up. This manual unrolling of the loop
  // decreases the number of hardware cycles between each read of the pin,
  // thus increasing sensitivity.
  uint8_t cycles = 17;
       if (*pin & bitmask) { cycles =  0;}
  else if (*pin & bitmask) { cycles =  1;}
  else if (*pin & bitmask) { cycles =  2;}
  else if (*pin & bitmask) { cycles =  3;}
  else if (*pin & bitmask) { cycles =  4;}
  else if (*pin & bitmask) { cycles =  5;}
  else if (*pin & bitmask) { cycles =  6;}
  else if (*pin & bitmask) { cycles =  7;}
  else if (*pin & bitmask) { cycles =  8;}
  else if (*pin & bitmask) { cycles =  9;}
  else if (*pin & bitmask) { cycles = 10;}
  else if (*pin & bitmask) { cycles = 11;}
  else if (*pin & bitmask) { cycles = 12;}
  else if (*pin & bitmask) { cycles = 13;}
  else if (*pin & bitmask) { cycles = 14;}
  else if (*pin & bitmask) { cycles = 15;}
  else if (*pin & bitmask) { cycles = 16;}

  // Discharge the pin again by setting it low and output
  //  It's important to leave the pins low if you want to
  //  be able to touch more than 1 sensor at a time - if
  //  the sensor is left pulled high, when you touch
  //  two sensors, your body will transfer the charge between
  //  sensors.
  *port &= ~(bitmask);
  *ddr  |= bitmask;

  //return cycles;
  Serial.println(cycles);
}

void Tone(String data){
  int idx = data.indexOf('%');
  int len = Str2int(data.substring(0,idx));
  String data2 = data.substring(idx+1);
  int idx2 = data2.indexOf('%');
  int pin = Str2int(data2.substring(0,idx2));
  String data3 = data2.substring(idx2+1);
  String melody[len*2];
  split(melody,len*2,data3,'%');

  for (int thisNote = 0; thisNote < len; thisNote++) {
    int noteDuration = 1000/Str2int(melody[thisNote+len]);
    int note = Str2int(melody[thisNote]);
    tone(pin, note, noteDuration);
    int pause = noteDuration * 1.30;
    delay(pause);
    noTone(pin);
  }
}

void ToneNo(String data){
  int pin = Str2int(data);
  noTone(pin);
}

void DigitalHandler(int mode, String data){
      int pin = Str2int(data);
    if(mode<=0){ //read
        Serial.println(digitalRead(pin));
    }else{
        if(pin <0){
            digitalWrite(-pin,LOW);
        }else{
            digitalWrite(pin,HIGH);
        }
        //Serial.println('0');
    }
}

void AnalogHandler(int mode, String data){
     if(mode<=0){ //read
        int pin = Str2int(data);
        Serial.println(analogRead(pin));
    }else{
        String sdata[2];
        split(sdata,2,data,'%');
        int pin = Str2int(sdata[0]);
        int pv = Str2int(sdata[1]);
        analogWrite(pin,pv);
    }
}

void ConfigurePinHandler(String data){
    int pin = Str2int(data);
    if(pin <=0){
        pinMode(-pin,INPUT);
    }else{
        pinMode(pin,OUTPUT);
    }
}

void shiftOutHandler(String data) {
    String sdata[4];
    split(sdata, 4, data, '%');
    int dataPin = sdata[0].toInt();
    int clockPin = sdata[1].toInt();
    String bitOrderName = sdata[2];
    byte value = (byte)(sdata[3].toInt());
    if (bitOrderName == "MSBFIRST") {
       shiftOut(dataPin, clockPin, MSBFIRST, value);
    } else {
       shiftOut(dataPin, clockPin, LSBFIRST, value);
    }
}

void shiftInHandler(String data) {
    String sdata[3];
    split(sdata, 3, data, '%');
    int dataPin = sdata[0].toInt();
    int clockPin = sdata[1].toInt();
    String bitOrderName = sdata[2];
    int incoming;
    if (bitOrderName == "MSBFIRST") {
       incoming = (int)shiftIn(dataPin, clockPin, MSBFIRST);
    } else {
       incoming = (int)shiftIn(dataPin, clockPin, LSBFIRST);
    }
    Serial.println(incoming);
}

void SS_set(String data){
  delete sserial;
  String sdata[3];
  split(sdata,3,data,'%');
  int rx_ = Str2int(sdata[0]);
  int tx_ = Str2int(sdata[1]);
  int baud_ = Str2int(sdata[2]);
  sserial = new SoftwareSerial(rx_, tx_);
  sserial->begin(baud_);
  Serial.println("ss OK");
}

void SS_write(String data) {
 int len = data.length()+1;
 char buffer[len];
 data.toCharArray(buffer,len);
 Serial.println("ss OK");
 sserial->write(buffer);
}
void SS_read(String data) {
 char c = sserial->read();
 Serial.println(c);
}

void pulseInHandler(String data){
    int pin = Str2int(data);
    long duration;
    if(pin <=0){
          pinMode(-pin, INPUT);
          duration = pulseIn(-pin, LOW);
    }else{
          pinMode(pin, INPUT);
          duration = pulseIn(pin, HIGH);
    }
    Serial.println(duration);
}

void pulseInSHandler(String data){
    int pin = Str2int(data);
    long duration;
    if(pin <=0){
          pinMode(-pin, OUTPUT);
          digitalWrite(-pin, HIGH);
          delayMicroseconds(2);
          digitalWrite(-pin, LOW);
          delayMicroseconds(5);
          digitalWrite(-pin, HIGH);
          pinMode(-pin, INPUT);
          duration = pulseIn(-pin, LOW);
    }else{
          pinMode(pin, OUTPUT);
          digitalWrite(pin, LOW);
          delayMicroseconds(2);
          digitalWrite(pin, HIGH);
          delayMicroseconds(5);
          digitalWrite(pin, LOW);
          pinMode(pin, INPUT);
          duration = pulseIn(pin, HIGH);
    }
    Serial.println(duration);
}

void SV_add(String data) {
    String sdata[3];
    split(sdata,3,data,'%');
    int pin = Str2int(sdata[0]);
    int min = Str2int(sdata[1]);
    int max = Str2int(sdata[2]);
    int pos = -1;
    for (int i = 0; i<8;i++) {
        if (servo_pins[i] == pin) { //reset in place
            servos[pos].detach();
            servos[pos].attach(pin, min, max);
            servo_pins[pos] = pin;
            Serial.println(pos);
            return;
            }
        }
    for (int i = 0; i<8;i++) {
        if (servo_pins[i] == 0) {pos = i;break;} // find spot in servo array
        }
    if (pos == -1) {;} //no array position available!
    else {
        servos[pos].attach(pin, min, max);
        servo_pins[pos] = pin;
        Serial.println(pos);
        }
}

void SV_remove(String data) {
    int pos = Str2int(data);
    servos[pos].detach();
    servo_pins[pos] = 0;
}

void SV_read(String data) {
    int pos = Str2int(data);
    int angle;
    angle = servos[pos].read();
    Serial.println(angle);
}

void SV_write(String data) {
    String sdata[2];
    split(sdata,2,data,'%');
    int pos = Str2int(sdata[0]);
    int angle = Str2int(sdata[1]);
    servos[pos].write(angle);
}

void SV_write_ms(String data) {
    String sdata[2];
    split(sdata,2,data,'%');
    int pos = Str2int(sdata[0]);
    int uS = Str2int(sdata[1]);
    servos[pos].writeMicroseconds(uS);
}

void sizeEEPROM() {
    Serial.println(E2END + 1);
}

void EEPROMHandler(int mode, String data) {
    String sdata[2];
    split(sdata, 2, data, '%');
    if (mode == 0) {
        EEPROM.write(Str2int(sdata[0]), Str2int(sdata[1]));
    } else {
        Serial.println(EEPROM.read(Str2int(sdata[0])));
    }
}

void SerialParser(void) {
  char readChar[64];
  Serial.readBytesUntil(33,readChar,64);
  String read_ = String(readChar);
  //Serial.println(readChar);
  int idx1 = read_.indexOf('%');
  int idx2 = read_.indexOf('$');
  // separate command from associated data
  String cmd = read_.substring(1,idx1);
  String data = read_.substring(idx1+1,idx2);

  // determine command sent
  if (cmd == "dw") {
      DigitalHandler(1, data);
  }
  else if (cmd == "dr") {
      DigitalHandler(0, data);
  }
  else if (cmd == "aw") {
      AnalogHandler(1, data);
  }
  else if (cmd == "ar") {
      AnalogHandler(0, data);
  }
  else if (cmd == "pm") {
      ConfigurePinHandler(data);
  }
  else if (cmd == "ps") {
      pulseInSHandler(data);
  }
  else if (cmd == "pi") {
      pulseInHandler(data);
  }
  else if (cmd == "ss") {
      SS_set(data);
  }
  else if (cmd == "sw") {
      SS_write(data);
  }
  else if (cmd == "sr") {
      SS_read(data);
  }
  else if (cmd == "sva") {
      SV_add(data);
  }
  else if (cmd == "svr") {
      SV_read(data);
  }
 else if (cmd == "svw") {
      SV_write(data);
  }
 else if (cmd == "svwm") {
      SV_write_ms(data);
  }
  else if (cmd == "svd") {
      SV_remove(data);
  }
  else if (cmd == "version") {
      Version();
  }
  else if (cmd == "to") {
      Tone(data);
  }
  else if (cmd == "nto") {
      ToneNo(data);
  }
  else if (cmd == "cap") {
      readCapacitivePin(data);
  }
  else if (cmd == "so") {
      shiftOutHandler(data);
  }
  else if (cmd == "si") {
      shiftInHandler(data);
  }
  else if (cmd == "eewr") {
      EEPROMHandler(0, data);
  }
  else if (cmd == "eer") {
      EEPROMHandler(1, data);
  }
  else if (cmd == "sz") {
      sizeEEPROM();
  }
}

void setup()  {
  Serial.begin(115200);
    while (!Serial) {
      ; // wait for serial port to connect. Needed for Leonardo only
    }
  Serial.println("connected");
}

void loop() {
  SerialParser();
}
blink.pyPython
Run this to check if the Arduino-python3 module is working
#!/usr/bin/env python
"""
 Blinks an LED on digital pin 13
 in 1 second intervals
"""

from Arduino import Arduino
import time

board = Arduino() # plugged in via USB, serial com at rate 115200
board.pinMode(13, "OUTPUT")

while True:
    board.digitalWrite(13, "LOW")
    time.sleep(1)
    board.digitalWrite(13, "HIGH")
    time.sleep(1)

Schematics

Block Diagram
Sketch1560830211113 sj3bjdzbts

Comments

Similar projects you might like

MeArm Robot Arm - Your Robot - V1.0

Project tutorial by Benjamin Gray

  • 24,000 views
  • 4 comments
  • 39 respects

MK2 Plus Robot Arm Controller

Project tutorial by Samira Peiris

  • 2,980 views
  • 5 comments
  • 18 respects

Control Arduino Robot Arm with Android App

Project tutorial by Slant Concepts

  • 14,210 views
  • 8 comments
  • 31 respects

Gesture Controlled Trainable Arduino Robot Arm via Bluetooth

Project tutorial by KureBas Robotics

  • 18,198 views
  • 43 comments
  • 135 respects

LittleArm: Arduino Robot Arm

Project showcase by Slant Concepts

  • 16,981 views
  • 2 comments
  • 76 respects
Add projectSign up / Login