Hello,
I wr[ch959]te this code in Python for Linux and module PySerial to echo bytes that sends from computer. The program works fine but i want to tell me your opinion ...
Gosh they're both remarkably similar aren't they. Small foot print too, can it be called from php? if yes, how?
In Linux try to change premissions to "Read/Write" to OTHERS in device /dev/ttyUSB0 (as root) .... Maybe this is dangerous but work.. In Windows i think you must change line 2 with $f = fopen("COM1","w+");
You can send data with ....
I write this little program in Python "Temperature" (modules: wx, serial), it reads the temperature from LM35 sensor and sends data to the computer every 1sec...
More : http://george.22web.net/downloads.html
Code:
Wiring:
int therPin = 2,val=0;
float cel = 0;
char incomingByte;
void setup() {
Serial.begin(9600);
pinMode(therPin, OUTPUT);
}
void loop() {
if (Serial.available() > 0) {
incomingByte = Serial.read();
if(incomingByte=='t' || incomingByte=='T'){
val = analogRead(therPin);
cel = (5.0 * val * 100.0)/1024.0;
Serial.println((long)cel);
}
}
}