Hardware Reference
In-Depth Information
# trap exit safely and start the webrick
trap("INT"){ server.shutdown }
puts "Running.. Hit Ctrl+c to stop."
server.start
You may have noticed that this script looks pretty close to the one from Chapter 5. You are correct. Only this time
I am running the gpio-setup.sh script when starting up the WEBrick HTTP server. Start up the WEBrick HTTP server
with the following command:
# ./server-power-control.rb
Open your favorite web browser and navigate to the Raspberry Pi's IP address. You should be greeted with a
screen that looks like Figure 10-17 .
Figure 10-17. The web page of the GPIO control
By using the two buttons on this page you can now control your mains device. If you click the on button you will
see your mains device turn on. You will also see the output from Figure 10-18 ; now just hit the back button on your
web browser.
Figure 10-18. The on button pressed
 
Search WWH ::




Custom Search