Serial HEX to ASCII to DMD

The Dot Matrix Display (DMD) is a 32x16 array of high-brightness LEDs for visually striking effects. [Product Page]
Post Reply
Stevel
Posts: 3
Joined: Sat Aug 24, 2013 8:02 am

Serial HEX to ASCII to DMD

Post by Stevel » Sat Aug 24, 2013 4:27 pm

Hi,
I am extremely new to the Arduino and any type of programming so my first project is going to be a challenge. But after seeing the Arduino and the Freetronics DMD panel I wanted to give it a try.
I want to monitor the serial port for a data string and display some of the string to the DMD in ASCII.
The details of the data are below.

STX D nnnn B C ETX
STX = 2 hex, start of text
ETX = 3 hex, end of text
D = Device number, this must match a number in the setup
nnnn = numbers or characters to be displayed
B = 0: GREEN
B = 1: RED
C = 0: Open
C = 1: Closed

So the following data should display 42.

0x02 0x80 0x20 0x20 0x34 0x32 0x30 0x30 0x03

So what I need it to do is monitor the serial port for data, when it sees 0x02 read the string.
If the device number matches the one setup in the program then display the next 4 characters in the string as ASCII to the display.

I have created a sketch that will read the character sent via the serial port and display them but I don’t know how to setup the conditions and convert the HEX to ASCII to be displayed.

Can anyone point me in the right direction on how to do this.
I have been looking at several web sites for information but have not found very much.

User avatar
stryker
Posts: 256
Joined: Sat Jan 14, 2012 2:44 pm

Re: Serial HEX to ASCII to DMD

Post by stryker » Sun Aug 25, 2013 12:36 am

Hi stevel

Strictly speaking, your serial traffic won't be hex, rather it will be a string of bits that can be represented to human readable form as a number in some base (your choice of 2-binary, 10-decimal, or 16-hex...whatever is your preference), or as the representation of a displayed ascii character. This means to filter by a value, your code is just going to need to refer to the data in a particular way so comparing it to hex 0x42 or char '*' are equivalent.

Can you post here your code as it is up to now? I don't see your attachment.

Cheers !
Geoff

Stevel
Posts: 3
Joined: Sat Aug 24, 2013 8:02 am

Re: Serial HEX to ASCII to DMD

Post by Stevel » Sun Aug 25, 2013 12:48 pm

Hi Geoff,

Thank you for your reply.

As I said in my post this is new to me, I only bought the Arduino and DMD panel just over a week ago and have spent 6 or so hours with it.
My code is extremely basic and was mainly done so I could experiment with creating different fonts for the panel. I wanted the largest font I could make that would display 4 characters. Which I found by using Arial narrow 16.

My objective is to receive the string via the serial port until it sees 0x03, and then extract the 4 characters from the string that are required to be displayed on the panel.
So 0x02 0x80 0x30 0x30 0x34 0x32 0x30 0x30 0x03 would be received and 0042 would be displayed on the DMD panel.

I have been looking through the arduino reference under serial and it looks like I could use the readBytesUntil() function because the string I will be receiving will always end in 0x03.
But it does not explain how to implement it in any detail.

I guess what I really need is a book that explains how to implement the functions in some detail.

Or maybe someone to guide me on which functions I should be using to start my sketch.

Cheers
Steve
Attachments
Serial_txt_DMD.zip
(1.05 KiB) Downloaded 331 times

phuchuyhdtv
Posts: 8
Joined: Sat Aug 31, 2013 4:58 am

Re: Serial HEX to ASCII to DMD

Post by phuchuyhdtv » Sat Aug 31, 2013 5:01 am

help me!!!!!!!!!!
i want Serial HEX to ASCII exto DMD and ascii extended characters?????????

User avatar
stryker
Posts: 256
Joined: Sat Jan 14, 2012 2:44 pm

Re: Serial HEX to ASCII to DMD

Post by stryker » Sat Aug 31, 2013 2:46 pm

Hi stevel

Is the output to the serial monitor what you were expecting? You've got it printing out the characters received - is that working for you?

The section where you output to the DMD has a problem that the x & y values the dmd.drawString gets to use will soon be negative. I haven't checked to see if that function will deal with that nicely, but x & y need to be positive values which represent the offset from the top left corner of the DMD in rows and columns at which the string will be displayed.

Since you only have the 4 characters to display on the DMD the final logic in your loop() function doesn't do that. But then I presume that's because you've not got to that final step and for this test you want to show all 6.

I think you shoud replace

Code: Select all

   for (byte x=0;x<DISPLAYS_ACROSS;x++) {
     for (byte y=0;y<DISPLAYS_DOWN;y++) {
       dmd.drawString( 0-(x),  1-(y),(serIn), 6, GRAPHICS_NORMAL );
       }
   }
with something like this to get it to display something

Code: Select all

dmd.drawString( 0,0, serIn, 6, GRAPHICS_NORMAL );
(ie there's no need for the two for() statements there)

Cheers !
Geoff

phuchuyhdtv
Posts: 8
Joined: Sat Aug 31, 2013 4:58 am

Re: Serial HEX to ASCII to DMD

Post by phuchuyhdtv » Sun Sep 01, 2013 4:01 am

i want Serial HEX to ASCII exto DMD and ascii extended characters?????????

User avatar
stryker
Posts: 256
Joined: Sat Jan 14, 2012 2:44 pm

Re: Serial HEX to ASCII to DMD

Post by stryker » Sun Sep 01, 2013 8:43 am

phuchuyhdtv wrote:i want Serial HEX to ASCII exto DMD and ascii extended characters?????????
Nobody can help you get to where you want to go unless you explain where you are now.

What output are you seeing now, and did my last post change anything for you?

phuchuyhdtv
Posts: 8
Joined: Sat Aug 31, 2013 4:58 am

Re: Serial HEX to ASCII to DMD

Post by phuchuyhdtv » Sun Sep 01, 2013 9:23 am

/*--------------------------------------------------------------------------------------
Includes
--------------------------------------------------------------------------------------*/
#include <SPI.h> //SPI.h must be included as DMD is written by SPI (the IDE complains otherwise)
#include <DMD.h> //
#include <TimerOne.h> //
#include "huy.h"
#include "huy1.h"
//#include "Arial_black_16.h"
//#include "ArialN16.h"
//#include "ArialN15.h"
//#include "Arial12.h"

//Fire up the DMD library as dmd
#define DISPLAYS_ACROSS 1
#define DISPLAYS_DOWN 1
DMD dmd(DISPLAYS_ACROSS, DISPLAYS_DOWN);

char serIn[8];

void ScanDMD()
{
dmd.scanDisplayBySPI();
}

void setup(void)
{

//initialize TimerOne's interrupt/CPU usage used to scan and refresh the display
Timer1.initialize( 1600 ); //period in microseconds to call ScanDMD. Anything longer than 5000 (5ms) and you can see flicker.
Timer1.attachInterrupt( ScanDMD ); //attach the Timer1 interrupt to ScanDMD which goes to dmd.scanDisplayBySPI()

//clear/init the DMD pixels held in RAM
dmd.clearScreen( true ); //true is normal (all pixels off), false is negative (all pixels on)`

Serial.begin(9600);
}

void loop(void){
byte b;
if(Serial.available()) {

int chars_in = 0;
while (Serial.available()>0 && chars_in <9){
serIn[chars_in] = Serial.read();
Serial.write( byte(serIn[chars_in]));

chars_in++;
}
Serial.println();
}

// if (byte(serIn[0]==96))
{

dmd.selectFont(huy);

dmd.drawString( 0, 0,(serIn), 8, GRAPHICS_NORMAL );//(serIn)

}

// else {}
}

phuchuyhdtv
Posts: 8
Joined: Sat Aug 31, 2013 4:58 am

Re: Serial HEX to ASCII to DMD

Post by phuchuyhdtv » Sun Sep 01, 2013 9:24 am

i want Serial HEX to ASCII exto DMD and ascii extended characters?????????

clibin009
Posts: 329
Joined: Mon Oct 23, 2017 2:57 am

Re: Serial HEX to ASCII to DMD

Post by clibin009 » Wed Jan 03, 2018 6:14 am

clb0103
michael kors outlet clearance
cheap jordan shoes
ugg boots outlet
oakley sunglasses outlet
coach outlet canada
mulberry
coach outlet online
coach outlet online
canada goose coats
ralph lauren outlet online
cheap ugg boots
adidas nmd r1
polo ralph lauren outlet
canada goose outlet
michael kors outlet online
michael kors outlet online
polo ralph lauren outlet online
cheap ugg boots
the north face jackets
canada goose jackets
fitflops sale
ray ban sunglasses discount
burberry handbags
michael kors outlet clearance
canada goose jackets
pandora jewelry outlet
uggs
coach factory outlet
ray ban glasses
cheap jordans
ugg boots sale
pandora jewelry
coach factory outlet online
moncler
ugg boots
michael kors outlet online
ugg outlet online
coach factorty outlet online
burberry handbags
nmd adidas
yeezy boost 350
michael kors outlet online
michael kors outlet clearance
polo ralph lauren outlet
uggs clearance
timberland outlet
christian louboutin shoes
pandora charms
polo ralph lauren outlet
ralph lauren outlet online
yeezy boost 350
coach purses
canada goose jackets
cheap nfl jerseys wholesale
nike sneakers
ugg outlet online
the north face outlet
moncler coats
north face sale
michael kors outlet online
ralph lauren outlet online
cheap ugg boots
ugg boots
canada goose coats
hermes outlet
canada goose sale
pandora uk
polo ralph lauren outlet online
north face jackets
pandora jewelry
toms shoes
christian louboutin shoes
cheap air jordans
louis vuitton factory outlet
michael kors outlet store
louboutin outlet
mulberry outlet uk
polo ralph lauren outlet online
michael kors outlet store
nike shoes
adidas outlet
uggs clearance
ugg outlet store
ralph lauren outlet online
canada goose outlet online
ugg outlet
nike outlet store
polo ralph lauren outlet online
hermes bags
coach factory outlet
canada goose jackets uk
cheap oakley sunglasses
louis vuitton outlet online
coach outlet online
coach outlet store online
longchamp sale
ugg boots
moncler sale
michael kors
adidas yeezy boost
red bottom heels
coach factory outlet online
uggs outlet
pandora charms outlet
nike outlet store online
north face jackets
pandora outlet
birkenstock outlet
fitflops sale clearance
nfl jerseys
cheap jordans free shipping
canada goose sale
adidas nmd runner
canada goose
mulberry handbags
ugg canada
ralph lauren outlet online
cheap jordan shoes
coach outlet online
canada goose jackets
canada goose jackets
ralph lauren sale
jordans
canada goose jackets
polo ralph lauren outlet online
cheap ugg boots
moncler outlet online
canada goose jackets
canada goose jackets
ugg outlet store
yeezy shoes
ugg canada
coach outlet online
pandora outlet
moncler outlet online
kate spade handbags
adidas shoes
canada goose sale
canada goose coats
pandora charms sale clearance
tory burch outlet online
hermes bag
gucci outlet online
louboutin outlet
canada goose jackets
cheap air jordans
kate spade handbags
coach factorty outlet online
cheap air jordans
bottes ugg
canada goose jackets
coach outlet online
michael kors outlet online
burberry handbags
pandora sale clearance
the north face outlet
michael kors outlet online
canada goose outlet
louis vuitton factory outlet
ugg outlet
ugg boots
michael kors outlet store
fitflop sandals
ferragamo outlet
oakley sunglasses for women
coach outlet online
mulberry uk
timberland outlet store
canada goose jackets
ralph lauren uk
valentino
caterpillar boots
ralph lauren
mlb jerseys
coach outlet
ugg outlet online
ugg boots
canada goose jackets
ugg boots
discount oakley sunglasses
pandora jewelry
hermens
coach factory outlet online
adidas yeezy boost
coach factory outlet online
philipp plein
tory burch outlet online
gucci outlet
canada goose outlet store
michael kors
cheap nike shoes
coach outlet store
coach outlet store
adidas nmd runner
coach outlet online
north face outlet
polo ralph lauren outlet
cheap jordan shoes
louis vuitton handbags
canada goose jackets
pandora jewelry store
ugg boots
nike outlet online
moncler uk
ferragamo shoes
adidas
ugg boots
ray ban sunglasses discount
cheap nfl jerseys wholesale
red bottoms
birkin handbags
uggs outlet
nike zoom
canada goose outlet
louboutin shoes
pandora jewelry outlet
fred perry polo shirts
oakley sunglasses outlet
uggs outlet
louis vuitton outlet store
yeezy boost 350
kate spade outlet
burberry outlet online
fred perry shirts
valentino outlet
coach handbags outlet
adidas yeezy shoes
polo ralph lauren outlet
canada goose jackets
cheap jordan shoes
ralph lauren outlet
michael kors
ray bans
michael kors outlet store
moncler outlet online
canada goose
pandora uk
pandora charms sale clearance
moncler jacket
columbia sportswear outlet
adidas campus shoes
pandora charms outlet
ralph lauren uk
air max shoes
uggs outlet
moncler jackets
polo ralph lauren outlet
pandora charms sale clearance
coach outlet online
mbt
ray ban sunglasses cheap
longchamp bags
moncler sale
coach outlet store online
uggs outlet
michael kors bags
uggs outlet
coach outlet online
coach outlet online
ugg boots
polo ralph lauren
moncler jackets
cheap oakley sunglasses
oakley sunglasses outlet
uggs outlet
christian louboutin sale
moncler outlet online
coach outlet online
ralph lauren
cheap jordan shoes
coach factory outlet
ugg boots outlet
ralph lauren sale
cheap oakley sunglasses
michael kors
coach outlet canada
cheap ray ban sunglasses
pandora charms sale clearance
canada goose coats
fitflops sale
ugg outlet
adidas superstars
adidas outlet store
ralph lauren outlet online
adidas nmd r1
uggs outlet
ugg outlet store
ugg boots
coach factory outlet
nike shoes
yeezy shoes
cheap jordans for sale
kate spade outlet online
canada goose outlet
supreme shirts
coach outlet online
coach outlet online
fitflop sandals
michael kors handbags
nfl jerseys
pandora charms
coach outlet store
uggs outlet
pandora charms
michael kors outlet store
adidas nmd r1
tory burch shoes
polo ralph lauren
mbt shoes sale
ugg boots women
coach outlet online
coach factory outlet online
salvatore ferragamo outlet
air max
ralph lauren
yeezy shoes
coach factory outlet online
red bottom
michael kors bags
mlb jerseys
ralph lauren uk
the north face outlet
air jordan shoes
polo outlet online
ray bans
adidas outlet online
discount ray ban sunglasses
hermes handbags
michael kors outlet online
coach factory outlet
mlb jerseys cheap
louis vuitton factory outlet
ralph lauren uk
kate spade outlet online
ugg outlet store
ugg outlet
louis vuitton outlet
kate spade handbags
adidas nmd r1
michael kors
canada goose outlet online
ray ban sunglasses discount
moncler jackets
canada goose coats
michael kors handbags outlet
adidas store
coach outlet online
michael kors outlet store
canada goose parka
adidas yeezy
longchamps
coach outlet online
uggs on sale
michael kors outlet store
nike outlet
air jordan retro
mbt
ray ban sunglasses sale
adidas yeezy boost
canada goose
christian louboutin shoes
nike sneakers
adidas ultra boost
ugg outlet
nike air max 97
uggs outlet
harden vol 1
canada goose jackets
timberland boots
moncler coats
adidas yeezy
coach outlet online
yeezy boost 350
fitflop shoes
longchamp outlet
pandora charms sale
ugg
canada goose sale
ray ban sunglasses outlet
kate spade outlet
canada goose jacket
longchamp outlet store
hermes bags
nike outlet online
canada goose jackets
uggs outlet
ugg boots
ugg sale
nike air max 97
longchamp bags
ugg boots outlet
coach outlet online
nike outlet store
nike air max 2018
yeezy boost
kate spade outlet online
adidas outlet store
canada goose jackets
canada goose outlet
adidas sneakers
kate spade outlet online
salvatore ferragamo shoes
ray ban sunglasses outlet
michael kors outlet online
supreme uk
michael kors outlet clearance
air jordans
michael kors outlet store
coach outlet store online
cheap ray ban sunglasses
north face outlet
adidas superstar shoes
kate spade handbags
pandora charms outlet
timberland outlet
moncler uk
coach factory outlet online
burberry outlet online
pandora jewelry
supreme clothing
retro 11
oakley sunglasses outlet
pandora charms outlet
moncler pas cher
burberry outlet
nike air max 2018
canada goose outlet
michael kors outlet canada
canada goose
michael kors outlet
adidas yeezy boost 350
ralph lauren outlet online
canada goose jackets
michael kors outlet clearance
canada goose coats
moncler coats
polo ralph lauren outlet
air max
coach factory outlet online
jordan shoes for sale
adidas outlet online
cheap ray bans
ralph lauren outlet online
pandora charms sale
canada goose jackets
louis vuitton outlet online
ugg boots
coach outlet store online clearance
coach outlet online
philipp plein outlet
birkenstock shoes
uggs on sale
coach factory outlet online
uggs outlet
cheap uggs
cheap oakley sunglasses
uggs outlet
supreme shirts
nfl jerseys
coach outlet online
ralph lauren
canada goose sale
burberry outlet online
michael kors outlet canada
coach factory outlet online
coach factory outlet online
clb0103

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests