mmiscool
Full Member
Send me a message if you want to help with a WEB OS project
Posts: 106
|
Post by mmiscool on Aug 30, 2012 17:33:56 GMT -5
Hello all, I have built a relay control board that can be operated from run basic. For this project I used www.seeedstudio.com/depot/relay-shield-p-693.htmland a standard arduino uno board. The code for the auduino is as follows. unsigned char relayPin[4] = {4,5,6,7};
void setup() { Serial.begin(9600); int i; for(i = 0; i < 4; i++) { pinMode(relayPin[i],OUTPUT); } }
void loop() {
char ser = Serial.read();
if(ser == 'o'){ digitalWrite(relayPin[2],HIGH); delay(2000); digitalWrite(relayPin[2],LOW); delay(10000); } if(ser == 's'){ digitalWrite(relayPin[1],HIGH); delay(2000); digitalWrite(relayPin[1],LOW); delay(10000); } }
The code for liberty basic is as follows and should be compiled and stored with the exe files as "arduinoout.exe" and should be stored in the Runbasic directory. You must install the arduino drivers and configure the comm port in the code below to the correct number.
open "command.in" for input as #mike input #mike, char.to.send$ close #mike
open "COM3:9600,n,8,1,ds0,cs0,rs" for random as #comm
print #comm, char.to.send$
close #comm end
The code for runbasic is. You can customize the arduino code to use any character as the control character and send it that character using the function below. print arduinoout("o") wait
function arduinoout(char.to.send$) open "command.in" for output as #mike print #mike, char.to.send$ close #mike
end function
Happy coding -Mike
|
|
|
Post by meerkat on Aug 31, 2012 4:35:07 GMT -5
I'm looking for a analog to digital converter. Does arduino have anything like that. I'd like at least 8 bit accuracy, and input of 0 to 12 volts. I can live with 0 to 5 volts maybe. Thanks for the help. Dan
|
|
mmiscool
Full Member
Send me a message if you want to help with a WEB OS project
Posts: 106
|
Post by mmiscool on Aug 31, 2012 17:20:24 GMT -5
arduino.cc/playground/CourseWare/AnalogInputIf you use the code example located there and combine it with the serial out library's for the arduino. Then using liberty basic and its comm port commands one could receive the information back to the computer via usb. It is totally possible.
|
|
|
Post by bruces on Jun 19, 2015 11:42:59 GMT -5
Hi mmiscool, I'm very familiar with Arduino and LB, but new to RB. I understand that the RB function opens a file and writes the char "o" to it. And the LB program opens this file and sends the char out the serial port. But how does the RB program signal the LB program that a command has been written, and needs to be read and sent? Is this related to naming the LB executable the same as the RB function?
Thanks-- (sorry for the newbness) Bruce
|
|
|
Post by kokenge on Jun 22, 2015 10:36:14 GMT -5
|
|
mmiscool
Full Member
Send me a message if you want to help with a WEB OS project
Posts: 106
|
Post by mmiscool on Jun 25, 2015 17:54:40 GMT -5
So you are communicating with a com port usinmg the browser and not a program on the rb server. Interesting.
|
|