Sep-30-2016, 05:27 PM
Hello, I'm new here !
My hobby is microcontrollers and now I'm doing a project where I could change the sound volume with buttons on my breadboard. I tried a program which can open a website by pushing a button on the breadboard which I took from the book that I read.
Here is that program from the book called "Make: AVR programming" by Elliot Williams
My hobby is microcontrollers and now I'm doing a project where I could change the sound volume with buttons on my breadboard. I tried a program which can open a website by pushing a button on the breadboard which I took from the book that I read.
Here is that program from the book called "Make: AVR programming" by Elliot Williams
## Simple demo
## Sits forever listening to serial port
## When you press button, opens website of your choosing.
## Extend this to many buttons and you'll have a physical
## web-launcher.
BOSS_SITE = "http://animal-dream.com/data_images/badger/badger1.jpg"
## or perhaps more topical...
XKCD = "http://xkcd.com/353/"
SERIAL_PORT = "COM5"
BAUD_RATE = 9600
import serial
import webbrowser
sp = serial.Serial(SERIAL_PORT, BAUD_RATE, timeout = 5)
sp.flush()
print ("Boss Button")
while(1): # Sit and wait forever
response = sp.read(1) # get one byte
if response == "O":
print "Got OK Byte. Waiting for button press."
elif response == "X":
print "Got Boss Byte! Alarm!"
webbrowser.open(BOSS_SITE)
else:
print "Got nothing. Still waiting."How do I change this code so I can change the sound volume on my computer ? I use windows 7.
