Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 06:40 18 Sep 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : I2C Read to array problem

Author Message
Bizzie
Senior Member

Joined: 06/07/2014
Location: Australia
Posts: 192
Posted: 08:02pm 31 Jul 2015
Copy link to clipboard 
Print this post

Hi all,

Has anyone tried reading a single byte of data into an array element?

I have a CGColorMax2 updated to "Colour Maximite MMBasic firmware V4.5" hooked up to one of BigMik's I/O panels by I2C (pullups enabled on panel).

Running the following code with variable t = 0 results in all 0's regardless of what pins of the PCF8574 IC are held high.
Changing the variable t = 1 all is fine!

' Test I2C

I2C open 100,500

I2C write &H20,1,1,0
Dim d1(2)
Pause 100
t = 1
Do
If t=0 Then
I2C read &H20,1,1,d1
Print MM.I2C,"==>",d1(0)
Else
I2C read &H20,1,1,d
Print MM.I2C,"==>",d

EndIf

Pause 500
Loop


Anyone see what I am doing wrong? 0r Have I stumbled across a bug?

Rob

Rob White
 
BobD

Guru

Joined: 07/12/2011
Location: Australia
Posts: 935
Posted: 08:35pm 31 Jul 2015
Copy link to clipboard 
Print this post

What about this
[code]
Do
If t=0 Then
I2C read &H20,1,1,d1(0)
etc
[/code]
you have created an array but when you use it you haven't said where you want to put the data. D1 without the array index would just be another variable but not your array.
 
Bizzie
Senior Member

Joined: 06/07/2014
Location: Australia
Posts: 192
Posted: 09:14pm 31 Jul 2015
Copy link to clipboard 
Print this post


Thanks BobD,

Knew it would be simple got a feeling my VB programming may of got in the way there!
Rob White
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025