egonzago
Posts: 1
Joined: Wed Jul 20, 2016 1:21 pm

Javascript for turn on and off pins

Wed Jul 20, 2016 1:29 pm

Hi guys,

I want to use a Raspberry pi 3 to control the access in some place.

The Rpi, via a webrowser is going to check in a remote database(MySQL) the access code and then grant or not the access.
To do this I need to turn on and then off some pins in the Rpi.

I know how to manipulate pins in PHP and Python, but the Rpi is just the client (Web client) then the code would be executed in the server, therefore no pins in the Rpi are going to turn on or off.

Until I know java runs locally, I made a small script in pi4j that turn on and off the pins, but I don’t know how to put in the HTML code of the web page?

Can someone help?

Thanks in advance

Ernesto

User avatar
topguy
Posts: 6527
Joined: Tue Oct 09, 2012 11:46 am
Location: Trondheim, Norway

Re: Javascript for turn on and off pins

Thu Jul 21, 2016 8:04 pm

If you have network access you could look-up the necessary information in the database directly from Python on the pi, why are you using a web-browser ? Are the user going to input something in the web-browser.

Yes you can run Java locally.
(You can also run Javascript directly with node.js.)

Edit:
A good browser will not give you access to hardware, but you can call another web-service from that page. So if you have a small web-service running on the Pi ( either in Python or node.js ) whose only purpose is to toggle the GPIO pins then you can trigger that from the web-page.

Return to “Java”