hi guys,
I've been searching a few days, but not really found something.
what i would really like to do is use a MySQL database to control my Arduino Mega(1280). so i can use a web interface to control my arduino.
i wand it to do like this because i have really good knowledge of php, HTML & CSS.
my arduino will be in my PC case it self so it will be always connected to my pc. it will mostly control a lot of leds in my pc case
i have already a local & internet webserver running so no problems on that side
if it is not possible to use a MySQL database to control the arduino.
i will probably use a php script to send strings or something similar to the arduino which will then set the corresponding output
i know this can be done because i've seen people do it:
tried to set this up but there was no support for windows)
Curently im trying to get this code working but not really succesfull, i keep getting the error "fopen(COM3): failed to open stream: Permission denied in E:\Scripting\Arduino-MEGA\webcontrol\index.php"
## index.php ##
$fp = fopen("COM3", "w");
while (true){
$i = ($i + 1) % 10;
echo "Wrote $i - the LED should flash (" . ($i % 2 == 0 ? ' 1 time ' : '2 times ') . ")\r\n";
fwrite($fp, chr($i));
sleep(3);
}
fclose($fp);
## Arduino code ##
int ledPin = 13;
int usbnumber = 0;
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
if (Serial.available() > 0) {
usbnumber = Serial.read();
}
if (usbnumber > 0) {
if (usbnumber % 2 == 0){
digitalWrite(ledPin, HIGH);
delay(300);
digitalWrite(ledPin, LOW);
delay(300);
}else{
digitalWrite(ledPin, HIGH);
delay(300);
digitalWrite(ledPin, LOW);
delay(300);
digitalWrite(ledPin, HIGH);
delay(300);
digitalWrite(ledPin, LOW);
delay(300);
}
usbnumber = 0;
}
}
i don't think its the arduino code, just php that can't connect to it, yes i checked arduino is at COM3, will keep looking to get it work
EDIT: got this code working, needed to use "\.\COM3" instead of just "COM3"
any help is appreciated
Mvg Maarten