hi,
here a proof of concept of interfacing arduinoBT with a nokia N73 phone via python for S60.
the python code is horrible (i m not really a coder) but it works and i hope that
this primitive demo leads to further developement and postings about BT and S60 MobPhones.
info about python for s60:
http://wiki.opensource.nokia.com/projects/Python_for_S60
what it does:
when the python scripts starts
it sends ascii 49 to the arduino BT which then returns the numbers 0-60
which are written into a file and stored on the memory card.
stupid i know
but its just a test.
the BT waits for a ascii 49 on the serial to send the numbers.
best
erich
here the arduino code:
/* Bluetooth wit S60 mobile Phone
*
*
*
*/
int i = 0; //counter
int LED = 13; // pin for LED
int RESET = 7; //reset pin for bluetooth
int val = 0; // serial port data
int track[61];
void ledblink() {
digitalWrite(LED, HIGH);
delay(100);
digitalWrite(LED, LOW);
delay(100);
}
void ledblink1() {
digitalWrite(LED, HIGH);
delay(500);
digitalWrite(LED, LOW);
delay(500);
}
void init_track() {
for (i=0; i<=60; i++) {
track = i;
- }*
*} *
void reset_bt(){ - // Reset the bluetooth interface*
- digitalWrite(RESET, HIGH);*
- delay(10);*
- digitalWrite(RESET, LOW);*
- delay(2000);*
}
*void config_bt(){ * - Serial.println("SET BT PAGEMODE 3 2000 1");*
- Serial.println("SET BT NAME BT_Arduino");*
- Serial.println("SET BT ROLE 0 f 7d00");*
- Serial.println("SET CONTROL ECHO 0");*
_ Serial.println("SET BT AUTH * 12345");_ - Serial.println("SET CONTROL ESCAPE - 00 1");*
*} *
void setup() {
- reset_bt();*
- config_bt();*
- pinMode(LED,OUTPUT);*
- pinMode(RESET,OUTPUT);*
- init_track();*
- Serial.begin(115200);*
- ledblink();*
}
void loop () { - val = Serial.read();*
- if (val != -1) {*
- if (val == 49) {*
- ledblink1();*
- for (i=0; i<=60; i++) {*
- Serial.print(i, BYTE);*
- delay(10);*
- }*
- }*
- }*
}
-----------------------------------------------------------------
and now the python script:
-----------------------------------------------------------------
# Read and write from to arduino bt board
import socket
def bt_connect(): - global sock*
- arduino_addr='00:07:80:82:1F:35' #add your arduino BT adress here*
- sock=socket.socket(socket.AF_BT, socket.SOCK_STREAM)*
- target=(arduino_addr,1) # serial connection to arduino BT*
- sock.connect(target)*
def bt_send_data(): - global sock*
- test = "1"*
- sock.send(test)*
def bt_receive_data(): - global sock*
- i = 0*
- buffer = []*
- while(i <= 60):*
- data = sock.recv(1)*
- print str(ord(data))*
- buffer.append(data)*
- i = i + 1*
- return buffer*
bt_connect()
bt_send_data()
track = bt_receive_data()
f = open('e:\track.txt','w')
for i in range (0,60):
_ f.write(str(ord(track*)))_
_ f.write("\n")*_
f.close()
print str("aus")
sock.close()