Go Down

### Topic: Shiftout a byte (Read 783 times)previous topic - next topic

#### stoopkid

##### Mar 04, 2011, 12:26 pm
Im defining my bytes like this:

Code: [Select]
`byte digit[10][7]={{1,1,1,1,1,1,0},//0                  {0,1,1,0,0,0,0},//1                  {1,1,0,1,1,0,1},//2                  {1,1,1,1,0,0,1},//3                  {0,1,1,0,0,1,1},//4                  {1,0,1,1,0,1,1},//5                  {1,0,1,1,1,1,1},//6                  {1,1,1,0,0,0,0},//7                  {1,1,1,1,1,1,1},//8                  {1,1,1,1,0,1,1}};//9`

but this doesnt work:
Code: [Select]
`shiftOut(dataPin, clockPin, MSBFIRST, digit[numb]);`

How do i convert the bytes to an int?

#### robtillaart

#1
##### Mar 04, 2011, 12:34 pm

You better use the individual bits in the byte

byte digit[10][7]={{1,1,1,1,1,1,0},//0
{0,1,1,0,0,0,0},//1
{1,1,0,1,1,0,1},//2
{1,1,1,1,0,0,1},//3
{0,1,1,0,0,1,1},//4
{1,0,1,1,0,1,1},//5
{1,0,1,1,1,1,1},//6
{1,1,1,0,0,0,0},//7
{1,1,1,1,1,1,1},//8
{1,1,1,1,0,1,1}};//9

becomes
byte digits[10] = { B01111110, B00110000, B01101101, B01111001, B00110011, B01011011 etc

Then the shift should work. (also take only 10 bytes of RAM iso 70)

succes,
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

#### stoopkid

#2
##### Mar 04, 2011, 12:46 pm
thanks, that worked except i had to put the 0's at the end and change it to LSBFIRST... i guess just from how i wired it.

Go Up

Please enter a valid email to subscribe