Beispiel #1
0
def main():
    # Instantiate a Grove Speaker on digital pin D2
    mySpeaker = upmGrovespeaker.GroveSpeaker(2)

    # Play all 7 of the lowest notes
    mySpeaker.playAll()

    # Play a medium C-sharp
    mySpeaker.playSound('c', True, "med")
def buzz(beeptime=1.0):
	# Instantiate a Grove Speaker on digital pin D2
	mySpeaker = upmGrovespeaker.GroveSpeaker(4)
	timeout = time.time() + float(beeptime)
	while time.time() < timeout:
		mySpeaker.playSound('c', True, "med")
		# Play all 7 of the lowest notes
		#mySpeaker.playAll()
		time.sleep(0.3)
Beispiel #3
0
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

from __future__ import print_function
import time
import pyupm_grove as grove
import pyupm_grovespeaker as upmGrovespeaker

# Create the button object using GPIO pin 0
button = grove.GroveButton(0)

# Instantiate a Grove Speaker on digital pin D4
mySpeaker = upmGrovespeaker.GroveSpeaker(4)

# Read the input and print, waiting one second between readings
while 1:
    print("{} value is {}".format(button.name(), button.value()))
    if button.value():
        mySpeaker.playSound('c', True, "med")
    time.sleep(1)

# Delete the button object
del button
Beispiel #4
0
 def getSpeaker(self, pin=4):
     if self.speaker is None:
         # Instantiate a Grove Speaker on digital pin D4
         self.speaker = upmGrovespeaker.GroveSpeaker(pin)
     return self.getProxyObject(self.speaker)