interfacing with raspiberry pi

Hi all,

I am having a little trouble with my code, I think it is just a syntax issue.

What I want to achieve is for the pi to play 50 different videos via keypad presses.
Pressing 01 will play 01.mp4, pressing 12 will play 12.mp4, pressing 30 will play 30.mp4 and so on.

Basically I have a keypad hooked up with arduino and it will output any 2 digit numbers via serial to the pi.
I was able to print out whatever the 2 digits pressed to display on the pi terminal.
However when I tried to have it play the video, it will display .mp4" not found.

I think there is just a syntax issue on this line of

#    os.system('omxplayer -o local ' + videoNumber + '.mp4 &')

This is my pi code

#!/usr/bin/env python2.7  

import serial
import sys, os

# some code to hide the terminal

os.system('clear')

device_port = serial.Serial('/dev/ttyACM0', 9600)

while 1:
    videoNumber = device_port.readline()
    videoNumber = videoNumber.strip('\n')

    print videoNumber 

    os.system('pkill omxplayer')
    os.system('omxplayer -o local ' + videoNumber + '.mp4 &')

device_port.close()

This is are arduino code if needed

#include <Keypad.h>

const byte ROWS = 4; // Four rows
const byte COLS = 3; // Three columns
// keymap
char keypad[ROWS][COLS] = {
  {'1', '2', '3'},
  {'4', '5', '6'},
  {'7', '8', '9'},
  {'*', '0', '#'}
};
// Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
byte rowPins[ROWS] = { 9, 8, 7, 6 };
// Connect keypad COL0, COL1 and COL2 to these Arduino pins.
byte colPins[COLS] = { 10, 11, 12 };

// Create the Keypad
Keypad kpd = Keypad(makeKeymap(keypad), rowPins, colPins, ROWS, COLS );

void setup()
{
  Serial.begin(9600);
}

int count = 0;
int keypresses[2];

void loop() {
  char key = kpd.getKey();

  if (key == '*' || key == '#'){
    count = 0;
  }

  if (key) {
    keypresses[count] = key-'0';
    count++;
    if (count == 2) {
      Serial.println(keypresses[0]*10+keypresses[1]);
      count = 0;
    }
  }
}

rotcivisme: I think there is just a syntax issue on this line of

#    os.system('omxplayer -o local ' + videoNumber + '.mp4 &')

That looks like a question for a Python Forum. This Forum is for Arduino code problems.

...R

Robin2: That looks like a question for a Python Forum. This Forum is for Arduino code problems.

...R

oh my bad then. I will try again on a python forum. thanks for letting me know

1) Do you get the videoNumber from Arduino?

2) I would normally add a time.sleep(1) between the stop and the start of the player

#!/usr/bin/env python2.7  
import os
import serial
import sys
import time

os.system('clear')

device_port = serial.Serial('/dev/ttyACM0', 9600)

while 1:
    videoNumber = device_port.readline()
    videoNumber = videoNumber.strip('\n')

    print videoNumber 
    os.system('pkill omxplayer')
    sleep(1)
    os.system('omxplayer -o local ' + videoNumber + '.mp4 &')