I am trying to avoid the previous mistake of jumping straight into the project without planning it out and looking for the most efficient way of getting to the final result.
What would be the fastest, easiest way of achieving the following:
I host a web page on an arduino web server. I can input a range of integer values from 0 to 10. I input 5 as an example, Arduino reads the value and stores it on one of the analog output pins. I use the value in further calculations such as if Value on an AO pin > 3, LED flashes with red light on a different pin.
Is it possible to achieve this and how do I do it? I already did a project that involved passing the Analog Input (temperature readings from a sensor) to a webpage, but that involved some PHP too. Can I somehow modify my codes?
Any suggestions, codes or tutorials will be much appreciated, so I can start learning.
The standard Arduino doesn't have "analog output" pins.
Instead, it uses PWM (pulse width modulation) on a digital output pin, to produce a signal that when averaged over time gives a DC voltage value.
You can certainly use the value you get from the web page to do other things, like decide when to flash an LED, etc. If you explain your project more clearly you can expect better suggestions.
I am trying to avoid the previous mistake of jumping straight into the project without planning it out and looking for the most efficient way of getting to the final result.
A very commendable way of approaching a project.
There are lots of examples of Arduino web servers which manipulate the Arduino pins etc.
The classic example is switching on a led from a web browser connected to an Arduino web server.
Google for "arduino web server switch led"
PHP will not be relevant to this solution since this server sided scripting language is not supported on an Arduino based web server.
What Arduino and what network device (ethernet/Wlan etc. ) are you going to use ?
jremington:
The standard Arduino doesn't have "analog output" pins.
Instead, it uses PWM (pulse width modulation) on a digital output pin, to produce a signal that when averaged over time gives a DC voltage value.
You can certainly use the value you get from the web page to do other things, like decide when to flash an LED, etc. If you explain your project more clearly you can expect better suggestions.
Hello jremington, thank you for getting back to me
Okay, so that's another obstacle in my project that I have to overcome. Perhaps I wasn't clear enough with what I want to do, but here is hopefully a better explanation: Web page is hosted on Arduino, I can choose a number out of range 0-5 and for example I pick 5. Arduino therefore registers that the number on the web page was changed and now its 5. Therefore as a result Arduino produces a 5V output (using PWM)
Is it possible to achieve this? I saw many tutorials that can switch the buttons off and on remotely using web pages, but is Arduino capable of constantly reading the values from web page and hence producing a new output?
Also, how do I pass the value to the Arduino? I saw many tutorials that show how an Arduino can pick up a sentence or a specific word from a web page but what about an integer? Because I want arduino to know that its an integer that it can operate with, add/subtract from it?
6v6gt:
A very commendable way of approaching a project.
There are lots of examples of Arduino web servers which manipulate the Arduino pins etc.
The classic example is switching on a led from a web browser connected to an Arduino web server.
Google for "arduino web server switch led"
PHP will not be relevant to this solution since this server sided scripting language is not supported on an Arduino based web server.
What Arduino and what network device (ethernet/Wlan etc. ) are you going to use ?
Hi 6v6gt,
thanks for your reply so I will be using Elegoo Mega 2560 board and Ethernet on the network side of things. I'm not doubting the hardware capabilities but I am concerned regards whether my code will be capable of constantly/repeatedly checking the value on the web page and as soon as it's changed produce a new output accordingly?
If you're really going the "Internet of Things" way look at the ESP8266. It even comes with a piece of example code that does almost exactly what you want: web page with button from where you can switch on and off an LED. Sending the reading of a sensor as web page is also easy.