Arduino

Has anyone interfaced to an arduino before? Advice and basic steps appreciated…

Matt

The Arduino will show up as a serial device - try running the Serial Line Indicator example in Communications examples to get started, and to identify the port.
The Arduino itself sees the USB connection as serial, and the App and Arduino can talk back and forth. You can use serial for data & command transfers, but not for loading software to the Arduino, as far as I can tell.

Hi Matt

Yes I have done this. I added a serial port to a web application then send commands to the Arduino via this. The only gotcha was I needed to use a memoryblock to assemble the command(s).

I’ve also done this. Didn’t use a memory block, just used simple ascii messages to communicate between the Arduino and the application.

ok, that worked. thanks. Having trouble converting ASCII string to an integer on the Arduino though…

I use

 Dim m As New MemoryBlock(1)
m.Int8Value(0) = 1
Dim s As String = m
Arduino.Write s
Arduino.Flush

Where Arduino is the name of the SerialPort

How about

dim s as String = chrb(1)
Arduino.Write s

or

Arduino.Write chrb(1)

[quote=15467:@matt Herron]Has anyone interfaced to an arduino before? Advice and basic steps appreciated…

Matt[/quote]

Yes i have…:wink:

Serial must be set to (8-N-1):

Serial1.Baud = Serial.Baud9600 'This is the default arduino baud, you may go for a higher value

Serial1.Bits = Serial.Bits8 
Serial1.Parity = Serial.ParityNone
Serial1.Stop = Serial.StopBits1

Serial1.DataCarrierDetect = False
Serial1.CTS = False
Serial1.DTR = False
Serial1.XON = False

That should be it. You set the baud rate to the same value as the arduino.
If you let me know what the exact thing is you want to do and/or have questions just ask.

You can use ASCII or UTF8 (default Xojo string encoding) to send data.
You may also use HEX or Binary (ChrB() function)

[quote=15472:@Wayne Golding]Hi Matt

Yes I have done this. I added a serial port to a web application then send commands to the Arduino via this. The only gotcha was I needed to use a memoryblock to assemble the command(s).[/quote]

That’s not really true.
Your better off setting the Encoding to ASCII for the strings, and read them as ASCII as well.
It’s not required (at least in my experience) to have memoryblocks.

on the arduino side you use the wiring code:

int myInt = 0;
myInt = int(stringvaluehere);

Link: http://arduino.cc/en/Reference/IntCast

I did a Telnet interface that hooks on the TCP/IP port. But it could as well serve on the serial port.
It accepts commands like “A0,?” and replies with “A0,2.345” means it measures the voltage on A0 port
it uses the commands “I, ?, F, A, P, D, V and E”
I = Identification
? = Help
F=Function Call (user defined function)
A=Analog Input Port
P=Pwm-Port
D=Digital-Port (Input or output)
V=Variable (iser defined variable)
E=Error
It got a bit to big (26k) so it does not run on all Arduinos right now, if anyone has interest to join in, let me know

Hi daniel,

I see, this looks very simple.
I’ve had such protocols wich works very well.

Once you have created a class wich is usable in TCPSocket, Serial and more other classes, it makes sense to have it working on those.

Hi guys, I have a couple of questions on the Arduino.
Can you write a program in RealBasic and transfer it to the Arduino controller and run it, instead of using the Arduino IDE? or can you just send commands in “real-time”?

How do I know what commands to send to the Arduino?

Thanks for any input. I just got my Arduino board a week ago and it would be great if I can write a program in Realbasic that sends commands to the Arduino in realtime.

[quote=71051:@Mario Prieto]Can you write a program in RealBasic and transfer it to the Arduino controller and run it, instead of using the Arduino IDE? or can you just send commands in “real-time”?

How do I know what commands to send to the Arduino?
[/quote]
You won’t be able to upload RB/Xojo programs to the Arduino. Instead program it in the Arduino IDE so that it will accept serial commands and you will be able to send commands in real time to the Arduino. The serial commands can be anything you want them to be: you could send words, letters, bytes or other information and have your Arduino program react based on what it receives.

There is no Xojo compiler for the Arduino compatible MCU’s.

Can you give some more info about what you want to do?

You might want to have a look at this: http://www.86duino.com/index.php?p=68
I have one of the Zeros now and will be testing it. So far, though I’m having trouble getting a Linux distro to boot into SSL on it. As soon as I get these kinks worked out, I am going to try getting XOJO console apps working on it.

Like!
I’m doing exactly that also.
Embedded Xojo

Do you mean you have a Zero working? I can’t seem to get mine to log onto my network using the Linux kernel I got off of their Forum.

http://embeddedxojo.blogspot.no/?m=1

Have you gotten it to boot headless with Linux?