question regarding use of variables

Any general or miscellaneous queries that do not fit into the other forum catagories

Moderators: Benj, Mods

Posts: 13
Joined: Wed Feb 18, 2009 3:24 am

question regarding use of variables

Postby IAB48 » Wed Apr 15, 2009 8:22 am

I'm writing a programme in flowcode that uses a keypad to determine what particular folder of music plays. The music is stored in various folders on a usb stick and the usb stick is plugged into a vmuisc2 module, whic in turn is connected to the pic microcontroller


If keypad 1 is pressed then the following sequence occurs

vmusic 2 is stopped
folder change to CD\
folder is then changed to reflect the keypad button pressed - in this case it would be folder1
vmuic2 is started to repeat all mp3 tracks in folder1.

so this would be
VST (cr)
cd\ (cr)
cd folderx (cr) where x reflects the keypad button pushed
VPR (cr)

As I want to have upto 20 folders I'm looking at ways to shorten the number of decisions

At present I have a macro that says is myvariable (which is the return of getkeypad) = 1 - no; then go to next decision
is myvariable = 2 no; then go to next decision

This would require 20 decisions potentially one for each button in a 4 x 5 keypad
The only line that is different in each decision branch is the CD folderx line where x could be anything from 1 through to 20

I was wondring what could be done to reduce the number of the decisions

I've tried storing the keypad into eeprom and recalling it later as a variable to send to RS232 port but without success. At best I can get the RS232 send to change to a * which is basically saying it is a non printable character.

I guess my thought is to recall the keypad number selected so I can set it direct to RS232

keypad value stored (somewhare as a variable)
component macros to send RS232
VST (cr)
cd/ (cr)
Cd folder
recall keypad variable
VPR (cr)

The intent being to insert the keypad value directly after folder ( with no spaces) rather then have a decision for each possible value.

Any thoughts please


Ian Burrows

User avatar
Matrix Staff
Posts: 14130
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4325 times
Been thanked: 4070 times

Re: question regarding use of variables

Postby Benj » Wed Apr 15, 2009 9:41 am

Hello Ian

It sounds like the problem you are haing is due to the subtle differences between decimal numbers and ASCII numbers. Incoming RS232 data is in the form of ASCII and this is probably why you are seeing the * characters during simulation.

There is more information regarding this available here.


Posts: 1
Joined: Fri Aug 06, 2010 7:47 am

Re: question regarding use of variables

Postby rustyroadie » Fri Aug 06, 2010 7:55 am

Hi Ian,

Have you managed to come right with the Vmusic? Would it be possible for you to share your code?