Displaying array contents on LEDs

General discussion on mikroC.
Post Reply
Author
Message
Jimbotnik
Posts: 42
Joined: 20 Jan 2010 14:27

Displaying array contents on LEDs

#1 Post by Jimbotnik » 16 Jul 2010 12:35

Hello,

I have some code which writes either 1's or 0's to populate an array of integers (int MyArray[14]).

This compiles fine, but when I try to add some code to display the content of some of the array elements (PORTB.B0 = MyArray[0]) I get compilation errors.

What am I doing wrong?

Thanks for any guidance,

Jimbo

PS I am using the PIC5 Dev board with a PIC16F887 chip

Sobrietytest
Posts: 619
Joined: 05 Jul 2008 06:05
Location: Thailand

Re: Displaying array contents on LEDs

#2 Post by Sobrietytest » 17 Jul 2010 12:58

Each array element contains 1 byte (i.e. 8 bits) in your code you're trying to assign 8 bits to one bit location.

PORTB.B0 can only contain 1 or 0.

PORTB = MyArray[0]; would work.

Jimbotnik
Posts: 42
Joined: 20 Jan 2010 14:27

Re: Displaying array contents on LEDs

#3 Post by Jimbotnik » 19 Jul 2010 12:40

Thanks Sobrietytest - that's good to know. I will read up on different data type sizes

Post Reply

Return to “mikroC General”