arduino and runbasic home automation
Aug 30, 2012 17:33:56 GMT -5
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.html
and a standard arduino uno board.
The code for the auduino is as follows.
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.
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.
Happy coding
-Mike
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.html
and 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