Global Moderator
UK
Online
Brattain Member
Karma: 137
Posts: 19024
I don't think you connected the grounds, Dave.
|
 |
« Reply #15 on: April 22, 2011, 12:57:07 pm » |
_read() = _rbits;
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 26
Intermediate Arduino user
|
 |
« Reply #16 on: April 22, 2011, 04:32:10 pm » |
What about it?
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Online
Brattain Member
Karma: 137
Posts: 19024
I don't think you connected the grounds, Dave.
|
 |
« Reply #17 on: April 22, 2011, 04:34:07 pm » |
_read isn't a function returning a reference, so the assignment isn't possible.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 26
Intermediate Arduino user
|
 |
« Reply #18 on: April 22, 2011, 04:36:22 pm » |
OK, so how would I make it so you could do a statement like: Serial.print(AM9111.read()); ?
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Online
Brattain Member
Karma: 137
Posts: 19024
I don't think you connected the grounds, Dave.
|
 |
« Reply #19 on: April 22, 2011, 04:38:51 pm » |
int AM9111::_read() { digitalWrite(_odp,0); digitalWrite(_wep,1); int rv = 0; bitWrite(_rbits,0,digitalRead(_IO[0])); bitWrite(_rbits,1,digitalRead(_IO[1])); bitWrite(_rbits,2,digitalRead(_IO[2])); bitWrite(_rbits,3,digitalRead(_IO[3])); _read() = _rbits; return rv; }
Have you ever thought why this routine would always return zero? (if it were to compile) Is that what you want?
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 26
Intermediate Arduino user
|
 |
« Reply #20 on: April 22, 2011, 04:41:48 pm » |
WHat i wanted was to have _read read the outputs of the ram and have _read = the output ex: out = 1101; _read = 13;
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Online
Brattain Member
Karma: 137
Posts: 19024
I don't think you connected the grounds, Dave.
|
 |
« Reply #21 on: April 22, 2011, 04:42:52 pm » |
If that's what you wanted, why does it return zero?
Your _write method also (unusually) returns a value that is always zero.
|
|
|
|
« Last Edit: April 22, 2011, 04:45:32 pm by AWOL »
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 26
Intermediate Arduino user
|
 |
« Reply #22 on: April 22, 2011, 04:45:47 pm » |
I changed, but still has an error, do i have to have it do: return _rbits; ?
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Online
Brattain Member
Karma: 137
Posts: 19024
I don't think you connected the grounds, Dave.
|
 |
« Reply #23 on: April 22, 2011, 04:46:16 pm » |
Did you initialise _rbits?
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 26
Intermediate Arduino user
|
 |
« Reply #24 on: April 22, 2011, 04:46:58 pm » |
how?
as in int _rbits?
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Online
Brattain Member
Karma: 137
Posts: 19024
I don't think you connected the grounds, Dave.
|
 |
« Reply #25 on: April 22, 2011, 04:48:51 pm » |
No, apart from the missing semicolon, that looks more like a declaration, not an initialisation.
The clue is, you did initialise a variable, but it wasn't _rbits.
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 26
Intermediate Arduino user
|
 |
« Reply #26 on: April 22, 2011, 04:49:58 pm » |
so, how should i do it?
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Online
Brattain Member
Karma: 137
Posts: 19024
I don't think you connected the grounds, Dave.
|
 |
« Reply #27 on: April 22, 2011, 04:51:10 pm » |
I'd probably forget about _rbits altogether, and use (I mean really use) "rv".
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 26
Intermediate Arduino user
|
 |
« Reply #28 on: April 22, 2011, 04:51:53 pm » |
ok, ill try it.
|
|
|
|
|
Logged
|
|
|
|
|
Global Moderator
UK
Online
Brattain Member
Karma: 137
Posts: 19024
I don't think you connected the grounds, Dave.
|
 |
« Reply #29 on: April 22, 2011, 04:53:11 pm » |
By the way, the spelling is "indeterminate", not "intermediate". ;-)
|
|
|
|
|
Logged
|
Pete, it's a fool looks for logic in the chambers of the human heart.
|
|
|
|
|