Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm trying to get my LED to blink over http. We are using FTP(WinSCP) and Putty. I have the raspberry connected right. I have the

I'm trying to get my LED to blink over http. We are using FTP(WinSCP) and Putty. I have the raspberry connected right. I have the code which is down below. But it's just not work. What do I do? Can you use the instructions and code given, please? Thank you.
image text in transcribed
image text in transcribed
Blink an LED with a Raspberry over HTTP Follow these steps to make an LED attached to a Raspberry blink after being triggered over the web with a browser. The first steps below will be to make sure that you can run a few files over the web. Then you will blink the LED (which must be protected with a resistor in series) Step 1. Make sure you can run scripts over the web. Using FTP (WinSCP) upload the file "toblink.py" to your Raspberry in text mode and place it in the directory /var/www/html so that they can be accessible over the web. Change its permissions to "755" (you can do this by right clicking on a file from the WinSCP window and then checking boxes or from command line using "chmod 755 tobilink.py"). These permissions will allow it to be executable over the web Run the file toblink.py with a browser like this: With a browser go to http://your_ip_address/toblink.py and you should see its response "Hello Python!". This confirms that you can properly run python scripts over the web. Step 2. Blink an LED over the web. Make sure to connect an LED (with a resistor in series) to the Raspberry just as you did in the previous assignment over SSH. To blink the LED with the script toblink.py make sure to connect the LED to pin 12 of the GPIO, or, edit the tobilink.py script and put the pin you are using everywhere where the pin 12 is used in it. To edit the tablink.py file, you can do any of the following Edit it locally on your computer and then upload it to overwrite the old one transferring it in text mode) Using the WinSCP window, double click on toblink.py in the Raspberry pane. The file should be opened for editing in a new Window that appears on your computer but when saved it actually saves remotely on the Raspberry Using SSH (putty) go to the location of the file (using cd dine) and then edit toblink.py by typing nano toblink.py and edit the file. Here are some shortcuts: Use controlek to kill a line. Go highlight some text and copy it to clipboard then do a right click of the mouse inside the command line console; this will paste in the console the contents of the clipboard Now, if you run the toblink py again over the web, it should cause the operating system to execute to link.py which then would be working the GPIO to blink the LED in the same way as when we tried doing the blinking via SSH (putty! li Troubleshooting Running a python file over the web laster www.datamay require that www-data has sudo privileges Normally we do NOT do this unless we absolutely have to because it effectively aves the default http user www.data superuser privileges. But we will for the #!/usr/bin/python print "Content-type: text/html " #header required to run over web import RPi.GPIO as GPIO #import Raspberry Pi GPIO library import time #import time library print "Hello Python! " I GPIO.setmode(GPIO. BOARD) #use physical pins on GPIO GPIO.setup(12, GPIO.OUT) #set pin 12 to be an output pin print "We assume that an LED in series with a resistor is attached to pin ng for j in range (0, 3): GPIO.output(12, GPIO.HIGH) time. sleep(1) #wait for half a second print "ON GPIO.output(12, GPIO.LOW) print "OFF time. sleep(1) #wait for half a second GPIO.cleanup() print "All done" nd

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases In Networked Information Systems 6th International Workshop Dnis 2010 Aizu Wakamatsu Japan March 2010 Proceedings Lncs 5999

Authors: Shinji Kikuchi ,Shelly Sachdeva ,Subhash Bhalla

2010th Edition

3642120377, 978-3642120374

Students also viewed these Databases questions

Question

1. Explain how technology has changed the learning environment.

Answered: 1 week ago