Need help help, just learning Python, following Raspberry project. Have this, as root in /etc/init.d:
#! /bin/bash
modprobe snd_bcm2835
amixer cset numid=3 1
python /home/pi/radio.py
#!/usr/bin env python
import time import sleep
import os
import RPi.GPIO as GPIO
# I found loads of BBC Radio streams from http://bbcstreams.com/
GPIO.setmode(GPIO.BCM)
GPIO.setup(23 , GPIO.IN)
GPIO.setup(24 , GPIO.IN)
while True:
if GPIO.input(23)==1:
os.system(‘sudo killall mplayer’)
os.system(‘mplayer -playlist http://bbc.co.uk/radio/listen/live/r1.asx &’)
if GPIO.input(24)==1:
os.system(‘sudo killall mplayer’)
os.system(‘mplayer -playlist http://bbc.co.uk/radio/listen/live/r6.asx &’)
sleep(0.1);
GPIO.cleanup()
Making it executable:
chmod 755 radio
I reboot and get this error:
ImportError: No module named sleep
It passes import time but gets stuck on import sleep