BlitzMax Forums/BlitzMax Programming/arduino

jhocking(Posted 2008) [#1]
Hi all, this isn't a big thing but it's something others may be interested in. I've been interested in using Blitz along with homebrew electronics, so I picked up an Arduino:

Using Nigel Brown's comm module ( ) I've been communicating between the Arduino board and Blitz. As a bare beginning to anyone interested in playing with this, here's how to turn an LED on/off by hitting the spacebar. Obviously this is a pretty small start, and rather pointless on its own; this is basically a "Hello World!"

First follow these directions to get the Arduino setup:

Now upload this program to the board (the firmware):
int ledPin = 13;
int msg;

void setup()
  pinMode(ledPin, OUTPUT);

void loop() 
  if(Serial.available() > 0) {;
    if(msg==1) {
      digitalWrite(ledPin, HIGH);
    else {
      digitalWrite(ledPin, LOW);

Finally run this code in BlitzMax (as mentioned above, get brown.comm from Nigel's website):
Import brown.comm

Graphics 640,480

Global msg:Byte=0

Global port:TComm = New TComm
port.Set("baud=9600 parity=N data=8 stop=1")

While Not KeyHit(KEY_ESCAPE)
	DrawText "Press SPACE to toggle LED",10,10
		msg = msg Mod 2
	DrawText msg,10,40


Using this along with miniB3D could make for some very interesting physical interfaces. Arduino is useful for working with all sorts of input devices (pressure sensors, light meters, whatever) as well as output devices (lights, motors, etc.)

I figure my next step will be to make things work with the Firmata standard that people have been developing; it's a standard firmware for Arduino so that you don't have to worry about programming the hardware.

jhocking(Posted 2009) [#2]
Just clicking the links to see if they are still good, look's like Nigel's page has lapsed. Hopefully that's only temporary because there were some useful things there, but in the meantime another serial communication module for BlitzMax is this one:

EDIT: Just noticed Nigel is one of the two people posting in that thread. So that actually bodes ill for this new link for serial communication, doh.

Brucey(Posted 2009) [#3]
Just noticed Nigel is one of the two people posting in that thread. So that actually bodes ill for this new link for serial communication, doh

wxCTB is part of wxMax.
It even works on Mac (which the official release of wxCTB does not). Given that my primary platform is Mac, I kind of had to make it work there :-p

Nigel Brown(Posted 2009) [#4]
@jhocking, site is a little broken at the moment but wxCTB is very good can recommend it, is also cross platform. Was debating an arduino purchase myself, if I do will probably start developing using wxCTB again.

jhocking(Posted 2009) [#5]
Thanks for the updates guys! Nigel I highly recommend picking up an Arduino. Even if you never do anything serious with it, it's a lot of fun to just hack around with and it's only like $30 to get a pre-built board.