arduino
BlitzMax Forums/BlitzMax Programming/arduino
| ||
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: http://www.arduino.cc/ Using Nigel Brown's comm module ( http://www.nigelibrown.pwp.blueyonder.co.uk/blitz/userlibs/index.htm ) 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: http://www.ladyada.net/learn/arduino/lesson0.html http://www.ladyada.net/learn/arduino/lesson1.html Now upload this program to the board (the firmware): int ledPin = 13; int msg; void setup() { Serial.begin(9600); pinMode(ledPin, OUTPUT); } void loop() { if(Serial.available() > 0) { msg=Serial.read(); 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.Open(3) port.Set("baud=9600 parity=N data=8 stop=1") While Not KeyHit(KEY_ESCAPE) Cls DrawText "Press SPACE to toggle LED",10,10 If KeyHit(KEY_SPACE) msg:+1 msg = msg Mod 2 port.WriteByte(msg) EndIf DrawText msg,10,40 Flip Wend port.Close() End 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. |
| ||
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: http://www.blitzmax.com/Community/posts.php?topic=75614 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. |
| ||
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 |
| ||
@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. |
| ||
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. |