DuinoMite new boards: T-shaped breadboard adapter, Wii-nunchuk to UEXT and ICSP adapters



Ken Segler again had nice idea for T-shaped breadboard adapter which brings all DuinoMite GPIOs in easy to access form to breadboard + adds +5V/GND bus on top and +3.3V/GND bus on bottom of the breadboard – small and elegant solution for all who want to experiment with DuinoMite / MaxiMite.

This is our first prototype, we will have stock of this board around end of February.


For all retro computer Game lovers there is good news, now there is easy way to connect Wii-nunchuk to DuinoMite! For this purposes two adapters were built:


one is with UEXT connector so connects directly to the DuinoMite UEXT connector, the other is with PIC-ICSP connector layout and could be wired with 6 pin ICSP cable to DuinoMite PIC programming ICSP connector – as DuinoMite uses bootloader for new firmware upgrades the ICSP connector is used just once when the bootloader is programmed then stays with no use, so interfacing the Wii-nunchuk is good use for the ICSP.

Wii-nunchuk offers: X-Y Joystick and 3-Axes accelerometer + 2 Buttons and works with I2C.

In this thread on TBS forum you can download ready to use Wii-nunchuk BASIC code which is tested to work just fine with the UEXT connector, to work with ICSP connector new soft-emulated I2C communication should be implemented in the firmware.

DuinoMite Project: Using LED as light sensor


Everybody knows that LEDs emit light when you apply voltage on them and current flows through them.

Not everybody knows that LEDs do the reversal too, when the LED is irradiated with light they generate voltage.The more bright is the LED the more voltage it generates.

I made small setup to prove this. First you need high-brigthness LED – I got 8000 mCd red LED and connect the cathode to GND and anode to PIN(1) of DuinoMite as on the picture above.

Then wrote this small code:

10 SETPIN 1,1 ‘setup PIN(1) as analog input
20 A = 0 ‘accumulator variable
30 FOR I = 1 TO 5000 ‘do 5000 times
40 A = A + PIN(1) ‘add the PIN(1) readings to Accumulator i.e. I amplify 5000 times the PIN(1) readings this way
60 PRINT A ‘print the result
70 GOTO 20

The 5000 loop is also good to not scroll so fast the print results 🙂

With not irradiated LED the readings are:

> run

If I point it to the red power LED on DuinoMite it reads:
> run

If I point to the yellow LED on Duinomite it reads:
> run

The RED and YELLOW LEDs are with same brightness, then why the readings are different?

The “sensor” LED is most sensitive to the light spectrum it emmits, so when irradiated with RED light it generate more voltage than when irradiated with YELLOW light.

Tomorrow using this feature I will tell you how to teach DuinoMite to recognize colors, using RED, GREEN, BLUE and WHITE LEDs I will build Color-meter and when irradiate the “sensors” with different color light DuinoMite will recognize it and print on the screen.

Now let’s go back to RED only leds and think what else we can do with them. What If I make row of LEDs and scan them sequentially? I will make some low resolution (5 mm dot) scanner.

I make next setup with 4 LEDs wired as “sensors”:


The code nave to be changed to scan for 4 analog inputs:

10 NBR = 100 ‘how much to amplify
20 OPTION BASE 1 ‘option base for the arrays
30 DIM P(4)
40 FOR I = 1 TO 4: SETPIN I,1: NEXT ‘make PIN1-4 as analog inputs
50 CLS
60 FOR I = 1 TO 4: P(I) = 0: NEXT ‘clear the accumulators
70 FOR I = 1 TO NBR ‘read the analog inputs NBR times and add to the accumulators
80 FOR J = 1 TO 4
90 P(J) = P(J) + PIN(J)
100 NEXT J
110 NEXT I
120 FOR I = 1 TO 4 ‘display as graphics bars on the Duinomite VGA screen
130 LINE (I*30,MM.VRES)-(I*30+25,MM.VRES-2*P(I)),1,BF
140 NEXT I
145 PAUSE 200 ‘wait and do it again
150 GOTO 50

When run I can see bar graph which change with the amount of light which fall on the LEDs.

You can see on this video I apply light on the LEDs with RED high intenity LED of same kind, and this generates a lot of response on the “sensor” LEDs.

The same principle is used in this video, it uses 8×8 LED matrix as multi touch touchscreen device, too bad I have no 8 Analog inputs on DuinoMite as if I had I would duplicate this project 🙂

Similar projects are also THIS and THIS

You could even make on the same principle Interractive LED table like THIS

DuinoMite Project: Tank fluids level metering by capacitance measurement


Using the capacitive measurement setup from here I will try to make project for measuring the fluid (water) level by measuring the capacitance.

I found on my desk the “TANK” – plastic empty candy box. Then put two stripes of self adhesive aluminum foil on the two sides of the box and measured with C-meter the tank empty and full with water.

The empty TANK capacitance was 12 pf:


the full with water TANK had 79 pf capacitance:


pretty good difference so using the same schematic with measurement of the charging time I set in the previous project I ran the same code:

10 PIN(1)=0 ‘sense pin will first pull the capacitor to GND and discharge
20 A=0 ‘accumulator
30 FOR I = 1 TO 1000 ‘measure 1000 times and average to remove noise
40 SETPIN 1,8 ‘discharge the capacitor
50 SETPIN 1,1 ‘start charging
60 A = A + PIN(1) ‘accumulate the readings
80 A = A / 1000 ‘now divide by 1000 to normalize the result
90 PRINT A ‘let’s see the result
100 GOTO 20

and got 3.14 value for empty and 2.34 value for full tank measurement.

we can scale these measurements for instance 0-100% by this formula

FULLPERCENTAGE = (3.14-A)/0.008

and as DM-BASIC arithmetic is with float points we will get easy the measurement in % from 0 to 100.

Now let’s make graphical presentation of the tank:

10 PIN(1)=0
20 A=0
30 FOR I = 1 TO 1000
40 SETPIN 1,8
50 SETPIN 1,1
60 A = A + PIN(1)
80 A = A / 1000
100 CLS
110 LINE (0,0)-(210,210),1,B
120 LINE (5,205)-(205,205-2*(3.14-A)/0.0078),1,BF
130 GOTO 20

With this code we display on the screen the TANK and the fluid level in it.

This is link to video which show the tank level metering in action -> LEVEL METERING

DuinoMite Project: Low cost Humidity measurement with SMTHS07 capacitive sensor


SMTHS07 is low cost EUR 5.00 capacitive Humidity sensor from Smartec. The datasheet of this sensor is here.

The sensor change it’s capacitance linear in range 20-95% with 0.6 pf/RH.

Now the question is will DuinoMite be able to detect so small capacitive changes of 0.6 pf?

Let’s do some experimenting first. I made small schematic on breadboard-mini with two resistors and the sensor:


then wrote small BASIC code:

10 PIN(1)=0 ‘sense pin will first pull the capacitor to GND and discharge
20 A=0 ‘accumulator
30 FOR I = 1 TO 1000 ‘measure 1000 times and average to remove noise
40 SETPIN 1,8 ‘discharge the capacitor
50 SETPIN 1,1 ‘start charging
60 A = A + PIN(1) ‘accumulate the readings
80 A = A / 1000 ‘now divide by 1000 to normalize the result
90 PRINT A ‘let’s see the result
100 GOTO 20

the result was steady:

> run

if I approach the sensor with wet fingers the reading go to

So the sensitivity is quite good! All I need is calibration of the sensor, but how to do this?

How to Preciese calibrate SMTHS07 is explained here .
Poor’s man calibration is to put the sensor it in refrigerator, the humidity in refrigerator is always 100%. As SMTHS07 is linear knowing the capacitance in just one point is enough to calibrate it.

DuinoMite Project: Implementing GSM remote control in BASIC with few lines of code


Today I will show you how easy is to use MOD-GSM module to place phone calls, to take calls from other phones, to send and receive SMS and how to add cellular remote control to any of your embedded projects.

MOD-GSM is quad band 850/900/1800/1900 MHz GSM module and cover all GSM frequencies used in the world. It’s based on SIM340DZ module and have build in antenna on board so you do not need to connect external antenna.

All you need is SIM card for your GSM operator, note the card should be with UNLOCKED PIN, you place it in the SIM connector, apply 12VDC and press the wake up button. If everything is OK the red LED will start blinking once per 2-3 seconds which means that the module is registered to the GSM network and ready for use.

MOD-GSM is controlled with UART commands at 9600,8,1,N settings and you can connect MOD-GSM directly to DuinoMite on the UEXT connector.

The control of MOD-GSM is made with AT commands, the full list of the AT commands is in the SIM340 user manual located here.

To play with the different commands and evaluate their action I wrote small DM-BASIC code:

10 MSG$=”” ‘MOD-GSM returned message
20 CMD$ = “” ‘MOD-GSM command
30 OPEN “COM3:9600” AS #1 ‘Open UEXT UART to talk to MOD-GSM
40 PRINT “CMD:”; ‘wait for command
50 C$ = INKEY$ ‘get character
60 IF C$ = “” THEN 100 ‘if no character is entered check if MOD-GSM didnt sent message
70 IF C$=CHR$(13) THEN PRINT #1,CMD$ : CMD$=””: PAUSE 250: ? : GOTO 40 ‘ send command
80 CMD$ = CMD$ + C$: PRINT C$; ‘otherwise add the character to the command
90 GOTO 50
100 IF EOF(1) THEN 50 ‘check if something is in the UART receive buffer
110 M$ = INPUT$(1,#1); ‘read character from the receive buffer
120 IF M$ = CHR$(13) THEN 150 ‘if this is CR print the message
130 IF M$ <> CHR$(10) THEN MSG$ = MSG$+M$ ‘else add the character to the message
140 GOTO 50 ‘go back check for keys on the keyboard
150 ? “(“;LEN(MSG$);”)”;MSG$: MSG$=”” ‘here you can print or process MOD-GSM message
160 GOTO 40

When you run this small program it waits you to enter commands and send to MOD-GSM when you press ENTER, meantime listening if MOD-GSM send back messages to us and display them. This is good when you want to check how MOD-GSM respond to different commands.

What I noticed is that SIM340D do not respond to low case commands like “at” at start, once you write “AT” then it accept also lower case commands, but good idea is to not use lower case to prevent bugs 😉


interesting commands which I saw in the PDF:

ATD<number>; – call phone <number>
ATA – answers incoming RING
ATH – hang up the line

AT+GSN returns the modem IMEI when I execure it I got back “353358014969443” message which is my MOD-GSM IMEI number

AT+ATI returns the SIM340 info, what I got when executed is:


notice it says the modem is SIM300D although the hardware is SIM340D I guess these two modules share same firmware and this is why the response is as SIM300, the only difference between SIM300 and SIM340 is that later have 4 bands but SIM300 only 3 bands coverage

AT+CSQ returns the quality of the GSM signal – when I execute it I got response:

+CSQ: 25,0

I decided to hack a little bit to see what these numbers means. I covered the module with two metal pans:


the CSQ value decreased to +CSQ: 12,0 🙂

when I removed the top cover it recovered to +CSQ: 21,0


so generally you can use this to test your signal quality and the higher this value is the better is the signal reception, the values according to SIM340 PDF are in range 0-31

AT+COPS? return the name of the operator to whom SIM card you put belongs
+COPS: 0,0,”GLOBUL” operator name

i.e. the SIM card I put belongs to GLOBUL GSM operator

AT+CSPN? show your SIM card operator to which network you are connected, when I executed this is what I got

i.e. the MOD-GSM works in BG GLOBUL GSM network

SIM340 have internal temperature sensor which you can use to measure the temperature

AT+CMTE? will return the ambient temperature of the module:
+CMTE: 1,25

which means my room remperature is 25 C


to place phone call with DuinoMite and MOD-GSM is quite simple here is the code to do this:

10 OPEN “COM3:9600” AS #1
20 PRINT #1, “ATD+35932626259;”

if you run this code you will ring to Olimex phone number with your MOD-GSM (please do not test your MOD-GSM with our phone number 🙂 )

quite simple huh?

you can use this phone call as ALERT for instance if you detect something and want to warn the phone owner – just place call with this two line code

now how we can “receive” calls?

10 OPEN “COM3:9600” AS #1
20 MSG$=””
30 IF EOF(1) THEN 20 ‘wait MOD-GSM to tell us something
40 M$ = INKEY$(1,1) ‘read one character
50 IF M$ = CHR$(13) THEN 100 ‘process incoming message
60 IF M$<> CHR$(10) MSG$ = MSG$ + M$
70 GOTO 30 ‘wait for new message
110 GOTO 20

so with 2 lines of code we can place phone call and with 8 lines of code we can detect incoming call.

Now tell me how many lines of code you would use to do same in C 🙂

Perhaphs many of you know these GSM garage door openers, what they do is to open your door when you call them. The trick is that they detect the incoming call, and if the call comes from known number the GSM module Hang-up the call so the calling phone is no charged, then open the door.

Let see how we can implement this!

There is two ways MOD-GSM to respond to incoming call: one is by simply returning “RING” the other is to respond with “RING” and caller number. The default state is simple RING so you have to turn on Caller Identification with “AT+CLIP=1” command, let’s modify above code so it detects incoming RINGs and check if they are from “secure” number and only if such number is detected to do the action.

5 PHONE$ = “+359897286123” ‘this is the phone number which trigger our module with incoming call
10 OPEN “COM3:9600” AS #1
20 MSG$=””
30 IF EOF(1) THEN 20 ‘wait MOD-GSM to tell us something
40 M$ = INKEY$(1,1) ‘read one character
50 IF M$ = CHR$(13) THEN 100 ‘process incoming message
60 IF M$<> CHR$(10) THEN MSG$ = MSG$ + M$
70 GOTO 30 ‘wait for new message
100 IF INSTR(MSG$,PHONE$) <> 0 THEN PRINT “SECURE INCOMING RING DETECTED!”: PRINT #1,”ATH” ‘if the call is from secure number, print message and hang-out the line so no charge
110 GOTO 20

So with 10 lines we implemented these expensive garage door openers? Not bad!

Sending and receiving SMS with DuinoMite and MOD-GSM

Now let’s see the commands for SMS. The SMS is very convenient way to send status info, small amount of data, like “DOOR IS OPEN”, “PIR SENSOR IS ACTIVATED” etc.

Also by receiving SMS commands like “TURN HEATER ON” or “CUT ELECTRICITY” you can easily add remote control to any of your embedded devices.

There are few commands to operate with SMS:

AT+CMGF – this set the SMS mode we will use TEXT mode so the command should be “AT+CMGF=1” when you start using SMS

AT+CMGDA=”DEL ALL” this command deletes all SMS messages, it’s good to execute it after you receive SMS to not full the MOD-GSM SMS memory with many SMS messages

Sending SMS:

send sms command is with this format:


so let’s send SMS, the code is:

10 OPEN “COM3:9600” AS #1
20 PRINT #1,”AT+CMGF=1″: PAUSE 250 ‘select SMS message format as TEXT mode
30 PRINT #1,”AT+CMGS=”+CHR$(34)+”+359897123342″+CHR$(34)+CHR$(13)+”HELLO WORLD”+CHR$(26) ‘send SMS to phone +359897123342 with message HELLO WORLD

only 3 lines of code are necessary! and you can put in the send string your temperature, parameters you want to monitor etc etc etc.

you can combine this code with code above and to send back SMS with status only when the SECURE phone number call you first.

Receiving SMS:

OK I send now SMS with content “Led=on” to MOD-GSM

when MOD-GSM receive SMS it notify me with message:

+CMTI: “SM”,1

so I have to monitor in my code for this in the received messages, then I can read the message with the command:


the result is:

+CMGR: “REC UNREAD”,”+359897123342″,,”12/02/01,20:01:51+08″

With this information I can execute SMS commands only when they come from my known SECURE number.

Here is the code to receive commands by SMS and execute them:

5 PHONE$ = “+359897286123” ‘this is the phone number which SMS we will process
6 CMD$ = “LED=ON” ‘ this is the command which to trigger my action
7 ACTION = 0 ‘ listen
10 OPEN “COM3:9600” AS #1
15 PRINT #1,”AT+CMGF=1″ : PAUSE 250 ‘ set TEXT SMS mode
20 MSG$=””
30 IF EOF(1) THEN 20 ‘wait MOD-GSM to tell us something
40 M$ = INKEY$(1,1) ‘read one character
50 IF M$ = CHR$(13) THEN 100 ‘process incoming message
60 IF M$<> CHR$(10) THEN MSG$ = MSG$ + M$
70 GOTO 30 ‘wait for new message
100 IF INSTR(MSG$,”+CMTI:”) <> 0 THEN 200 ‘ new SMS arrived
105 IF INSTR(MSG$,PHONE$) <> 0 THEN 230 ‘ the SMS is from secure number
106 IF INSTR(MSG$,CMD$) <> 0 THEN 250 ‘ we recognized command
110 GOTO 20
200 ACTION=1 ‘ SMS is ready to be read
210 PRINT #1, “AT+CMGR=1” : PAUSE 200 ‘ read the SMS in memory
220 GOTO 20
230 ACTION=2 ‘ SMS comes from secure phone
240 GOTO 20
260 ACTION = 0: PRINT #1, “AT+CMGD=1” ‘delete the SMS
270 GOTO 20

so this 23 lines code receives and executes commands from secured phone number.

With this code above I hope you understood how easy is to control embedded devices vis GSM cellular network and DuinoMite. It took me two hours to write the code and this article, you can try to do same in other language and tell me the result 🙂

DuinoMite controls MP3 player – Add voice and music to your embedded projects

MOD-MP3-X is smart MP3 player build with VS1053 MP3 decoder and STM32F103RBT6 Cortex M3 microcontroller. It can work in two modes – stand alone MP3 player and Smart MP3 player controllable via RS232. In stand alone mode you can control MOD-MP3-X with slide switch to play/stop forward/reverse and increase / decrease the volume.

In Smart MP3 mode you can load MP3 files on the MOD-MP3-X SD-card if you connect with USB to computer, or you can send commands via RS232.

To play file with Duinomite is very simple you just have to send to MOD-MP3-X via RS232 this message: “PSONGNAME FILE.MP3” and to stop it you should send “C”

MOD-MP3-X responds to the commands and you can play with the different commands using this simple BASIC code:

10 OPEN “COM3:9600” AS #1 ‘open UEXT RS232 port
20 INPUT “CMD: “,CMD$ ‘ask for command
30 PRINT #1, CMD$+CHR$(13); ‘send to MOD-MP3-X + CR
35 PAUSE 300 ‘wait the command to be executed
40 IF EOF(1) THEN 20 ‘if there is response from the MOD-MP3
50 PRINT INPUT$(1,1); ‘read and print it
60 GOTO 40 ‘loop forever

with this code you can check all commands which are written in MOD-MP3-X user manual and see what they do.

OK then let’s write small code which plays the song “DUHAST.MP3” from my SD card when I press DuinoMite-Mini user Button, then to stop the song when the button is pressed again .

the code is:

10 OPEN “COM3:9600” AS #1 ‘open UEXT RS232 port
30 DO: PAUSE 100: LOOP UNTIL PIN(0)=1 ‘wait button to be pressed
40 PRINT #1, “PSONGNAME DUHAST.MP3” ‘start playing the song
50 PAUSE 1000 ‘wait 1 second
70 DO: PAUSE 100: LOOP UNTIL PIN(0)=1 ‘wait button to be pressed
80 PRINT #1, “C” ‘stop playing the song
90 CLOSE #1

Here is link to video which show how this program runs: http://youtu.be/kW_vReFMhkUImage

DouniMite Project: Knock Knock Knocking on heavens door!


everybody knows this song 🙂

Today I decided to experiment a little bit with pizzo sensors and DuinoMite. We used to produce car alarm systems 20 years ago and I have plenty of piezzo disks in my bin, they are with 20 mm diameter and we used them to produce shock sensors which detect impact on car’s body.

I carefully soldered 1Mohm resistor in parallel with the piezzo disk and with two wires connected between GND and PIN.1 on DuinoMite-Mini.

Then used pvc tape to attach to my desktop, so the sensor will vibrate with every desktop vibration. Piezzo sensors generate electricity when subject to physical force, as usual Wiki is good reference if you want to learn more about them http://en.wikipedia.org/wiki/Piezoelectric_sensor

generally you should think for the Piezzo sensor as capacitor, this is the reason to add the 1Mohm resistor in parallel to discharge the Piezzo once it generates the voltage when vibrating.

I looked at the generated signal with oscilloscope and the amplitude of the generated voltage was about 0.05V with light knocks near it, up to 3-5V when hit directly on the sensor. The 1Mohm resistor discharge it for about 25-40 milli seconds.

Now I’m ready to read it and wrote this small code:

10 SETPIN 1,1 ‘setup PIN(1) as analog input
20 DO WHILE PIN(1) < 0.01: LOOP ‘wait until you detect voltage above 0.01V
40 PAUSE 60 ‘wait enough to discharge the piezzo
50 GOTO 20 ‘endless loop

run the code and the result was as expected, the sensor was detecting every of my knocks around it.

here is video demonstrating how DuinoMite detects knocks http://youtu.be/tdVYdd6sCVg

Now this is good ground for other fun projects like – electric door which you open by knocking with secret knock sequence like on this video: http://www.youtube.com/watch?v=zE5PGeh2K9k, or stairs which light on when you step on them like on this video: http://www.youtube.com/watch?v=aYH5J43DapU



There is FIRMWARE WISHLIST on Ken Segler Designs forum and I post there a lot with requests for this or that command to be add 🙂

As the DM-BASIC code is over 30 000 lines I never looked at it in detail, just if wanted to see how some command works I was looking at the specific code which implements it.

Overall I though it’s difficult and confusing to touch in so big code as I could easily mess up something with the other commands.

Iggy from KSD forum did some commands recently for me and when he submited them to Ken to include in the mainstream code I was amazed how simple was to add command to DM-BASIC.

For instance he implemented function DM.VMEM which returns the first address of the video RAM as Nick requested on TBS forum, the code insertion was:

in graphics.h there is one line to add:

// Ingmar
{ “DM.VMEM”, T_FNA | T_NBR, 0, fun_vmem },

this row define the name of the new statement: “DM.VMEM” then define it as FUNCTION returning NUMBER and will call fun_vmem() to get it’s value

and in graphics.c there is this code snip to add:

// Returns lower 16 bits of video buffer.
// This assumes the upper 16 bits always start 0xa000, maybe we should return all 32 bits?
void fun_vmem(void) {
int vmem = (int)VA;

vmem &= 0x0000ffff;
fret = (float)vmem;

so with adding 5 lines of code we already have new DM.VMEM function which returns the address of the Video buffer!

WOW! I didn’t expect it to be SO easy!

now let’s see how he implemented SHIFTOUT:

first define it in external.h
// Ingmar
{ “SHIFTOUT”, T_CMD, 0, cmd_shiftout },

this time this is COMMAND i.e. do not return value and the code is at cmd_shiftout()

and the code is put in external.c

// This is invoked as a command (ie, shiftout(Dpin, Clkpin, Mode, OutStr, NumBits) )
// Remember that the string returned in outstr will have the length in byte 0, outstr[0]

#define uDly(a) {WriteCoreTimer(0); while(ReadCoreTimer() < a);}

void cmd_shiftout(void) {
int dpin, cpin, mode, nbits;
int ix, iy; // loop counter
int cnt; // number of bytes to output.
unsigned char mybyte;

char * outstr;

const int BDLY = 3; // Determines clocking rate. # of CoreTimer cycles.

getargs(&cmdline, 9, “,”); // Get the arguments, we should have five, comma seperated.

if (argc < 9) error(“Invalid syntax”); // Test number of arguments given.

dpin = getinteger(argv[0]); // Data pin
cpin = getinteger(argv[2]); // Clock pin
mode = getinteger(argv[4]); // Mode
outstr = getstring(argv[6]); // String to clock out,treated as an array of bytes.
nbits = getinteger(argv[8]); // Number of bits to clock out

if (nbits < 1 || nbits > (outstr[0] * 8)) error(“Too many/few bits”);

if (dpin < 0 || dpin > NBRPINS || cpin < 0 || cpin > NBRPINS) error(“Invalid pin number”);
if (ExtCurrentConfig[dpin] >= EXT_COM_RESERVED || ExtCurrentConfig[cpin] >= EXT_COM_RESERVED) error(“Pin is allocated to a communications function”);

// At this point we should have a valid number of arguments and some possibly valid IO pins.

cnt = (nbits – 1) / 8; // Tells us who many complete bytes to loop over.
cnt++; // at least one byte even if it is a partial byte.

ExtSet(cpin,0); // CLK pin low

if (mode == 0) { // shift bits out LSB first starting at the END of the string.

for (ix=0; ix<nbits; ix++) { // loop through all bits
iy = ix / 8; // byte offset

mybyte = outstr[outstr[0]-iy]; // current byte being output

if (mybyte & (1 << (ix & 0x07))) {
ExtSet(dpin,1); // output a 1
} else {

ExtSet(cpin,1); // CLK high
ExtSet(cpin,0); // CLK low

} // next bit

} else { // shift bits out MSB first starting at the BEGINNING of the string.

for (ix=0; ix<nbits; ix++) { // loop through all bits
iy = (ix / 8) + 1; // byte offset

mybyte = outstr[iy]; // current byte being output

if (mybyte & (128 >> (ix & 0x07))) {
ExtSet(dpin,1); // output a 1
} else {

ExtSet(cpin,1); // CLK high
ExtSet(cpin,0); // CLK low

} // next bit



the code above is well commented and do not need my comments, again it was very simple to add!

Now let’s hack a bit! I wanted to make my own command to prove the concept!

If you want to do the same:

First you have to obtain the tools to compile DM sources from Microchip web

Download MPLAB 8.80 (166MB) and PIC C32 compiler v1.11b (73 MB) and install them

Then download DM-BASIC latest sources from Olimex Web page http://www.olimex.com/dev/

Unpack them in working directory and try the project. Note I had to setup the C32 locations manually and to change search path for Olimex.h to build the project successfully. The HEX is compiled and located in OUTPUT directory and named OLIMEX.HEX, use the Bootloader tool to burn in DuinoMite.

I compiled the source first and downloaded to DuinoMite. Everything works OK!

OK then let me try to add HELLO command which writes “Hello World” on the screen

I add in misc.h this line which defines my command:

{ “HELLO”, T_CMD, 0, cmd_hello },

and in misc.c the code to be executed when HELLO is met in BASIC:

void cmd_hello(void) {

MMPrintString(“Hello world!\r\n”);

Now let’s compile everything and bootload and try!

it works!

So using this approach you can define ANYTHING you want to have in DM but you miss it, only you should have some basic C knowledge, then to be not afraid of learning new stuff and hacking.

I will personally try to implement next: RCTIME command which will measure capacitance on the GPIO pin in the next days and post the result.

This way you can build your own version of DM-BASIC which to add specific functionallity which is not possible to be done otherwise in pure BASIC. Do not forget DM-BASIC is open source project with GPL 3.0 licensee so whatever you do do not forget to make your sources also available, so the community can benefit from your contribution and the project move forward!

Happy hacking!

MOD-VGA Gameduino based design is complete


Now we have to run the first prototypes and verify we did everything correctly.

We add PS2 keyboard and  32MB of SDRAM to support higher resolutions.

The schematic is available for preview here: http://www.olimex.com/dev/DUINO/DUINOMITE/MOD-VGA-Rev-A.pdf

DuinoMite Project: Measuring Earths Magnetic Field with MAG3110


MAG3110 is nice digital 3-axis magnetometer. We built MOD-MAG which is board with MAG3110 and UEXT so this magnetometer can easily be connected to any of our development boards. The example here is with DuinoMite-Mini.

MAG3110 is pretty sensitive with 0.1 uT resolution and have full scale +-1000uT. For reference the Earth magnetic field varry from equator to poles in range 25-65 uT, so it’s possible to measure Earth’s magnetic field with MAG3110 and make for instance Compass or to scan infield for buried metal objects which affect Earth magnetic field or make tons of other interesting projects.

WiKi as usuall is great source for information on Earth magnetic field: http://en.wikipedia.org/wiki/Earth’s_magnetic_field

The complete MAG3110 data sheet is available at Freescale web: http://www.freescale.com/files/sensors/doc/data_sheet/MAG3110.pdf

Geomagnetic storms influence our life and you can read more for them here http://en.wikipedia.org/wiki/Geomagnetic_storm, moderate and intensive Geomagnetic storms could be detected and monitored with MAG3110.

For finer resolution magnetic fields are measured with fluxgate magnetomeres which can sense down to 0.01 uT, here is nice article about the fluxgate magnetometers: http://www.geotech1.com/pages/mag/projects/fmx1/fmx1.pdf

MAG3110 digital interface is I2C so very easy to read it with DuinoMite.
Here is small code I wrote to test MOD-MAG which have on board MAG3110 and UEXT connector:

10 OPTION BASE 0 ‘to make sure we have base 0
20 ID = 0: DIM AXES(6) ‘ID variable and AXES array
30 I2CEN 100,100 ‘enable I2C
40 I2CRCV &H0E, 0, 1, ID, 1, 7 ‘read MAG3110 ID (C4)
50 PRINT “ID = “;HEX$(ID) ‘should print C4 if MOD-MAG is attached
60 I2CSEND &H0E, 1, 2, &H11, &H80 ‘ctrl reg2, auto resets enbl
70 I2CSEND &H0E, 0, 2, &H10, &H01 ‘ctrl reg1, active mode
80 I2CRCV &H0E, 6, AXES(0), 1, 1 ‘read 6 bytes from addr 1
90 PRINT “X =”; HEX$(AXES(0)*256+AXES(1)); TAB(10) ‘X axe
100 PRINT “Y =”; HEX$(AXES(2)*256+AXES(3)); TAB(20) ‘Y axe
110 PRINT “Z =”; HEX$(AXES(4)*256+AXES(5)) ‘Z axe
120 IF INKEY$ <> “” THEN 200 ‘end if key is pressed
130 PAUSE 300 ‘wait a little
140 GOTO 80 ‘read and print again
200 I2CDIS ‘disable I2C


as you can see the magnetometer on my desk do not give steady values, this is because we are surrounded by lot of invisible magnetic noise radiated from the computers, monitors, and so on electronics around us.

Previous Older Entries Next Newer Entries