We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi , Im interrested abt controlling arduino via web hosting with processing
i used this processing code
import processing.serial.*;
Serial port;
void setup() {
/* This part must be altered to fit your local settings. The number in brackets after "Serial.list()" is where you declare what COM port your Arduino is connected to.
If you get error messages, try a different number starting from 0 (e.g. 0, 1, 2, 3...) . */
port = new Serial(this, Serial.list()[0], 9600); // Open the port that the Arduino board is connected to, at 9600 baud
}
void draw() {
String onoroff[] = loadStrings("http://ardhielka.atwebpages.com/LEDstate.txt"); // Insert the location of your .txt file
print(onoroff[0]); // Prints whatever is in the file ("1" or "0")
if (onoroff[0].equals("1") == true) {
println(" - TELLING ARDUINO TO TURN LED ON");
port.write('H'); // Send "H" over serial to set LED to HIGH
} else {
println(" - TELLING ARDUINO TO TURN LED OFF");
port.write('L'); // Send "L" over serial to set LED to LOW
}
delay(7000); // Set your desired interval here, in milliseconds
}
simple arduino code
const int ledPin = 13; // the pin that the LED is attached to - change this if you have a separate LED connected to another pin
int incomingByte; // a variable to read incoming serial data into
void setup() {
// initialize serial communication:
Serial.begin(9600);
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
}
void loop() {
// see if there's incoming serial data:
if (Serial.available() > 0) {
// read the oldest byte in the serial buffer:
incomingByte = Serial.read();
// if it's a capital H (ASCII 72), turn on the LED:
if (incomingByte == 'H') {
digitalWrite(ledPin, HIGH);
}
// if it's an L (ASCII 76) turn off the LED:
if (incomingByte == 'L') {
digitalWrite(ledPin, LOW);
}
}
}
now i wondering to monitoring an input from arduino with processing, and then display it to my website. I.E when i pushed/not a button the processing send it to my web page.
what should i do ? sry for my bad english regrads newbie :)
Answers
I think you must write it to your textfile on the webspace.
thx for ur respond, i did that way for controlling my led. But i confuse how it works when i send from processing to my web. Im newbie abt using loadString. Could u pls give simple program for sending a command to web space and what i need in database?