KermMartian wrote:
Well, there's the handy-dandy Get() and Send() calls in BASIC, so I don't see any particularly good reason
not to offer BASIC programmers an interface to use it! Also, I don't think the speed of Axe would necessarily be too important here, do you? Why would you need speed?
Tell me about your existing code and hardware. My experience with my
Arduino - TI Link Protocol project and
globalCALCnet (as well as my EE degrees and two decades of fun experience! </tooting-own-horn>) tell me that there's no extra hardware needed, just two digital I/O pins and ground.
Edit: I have a lot of problems with
this code that you shared with us. Starting from nowhere in particular, besides the baffling combination of analog and digital pins, you never update the
time variable around line 55, so your timeout there won't work. You also don't set the output pins as high to start, which is problematic.
Comeon
It's my first arduino project. I program the thing 2 days now
I changed the code (updating time correctly)
Code: void setup(){
pinMode(2,OUTPUT);
pinMode(3,OUTPUT);
Serial.begin(9600);
}
/////////////////////////////////////////////////////////////////////////////
///~~~~[ IO SEND function ]~~~~///////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
///~~~~[ IO GET function ]~~~~///////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
int IOget(int timeout){
int time=0;
int number=0;
for(int i=0;i<8;i++){
////////////////////////////////////////////////
while(time!=timeout && analogRead(A4)>200 && analogRead(A5)>200){
time++; //escape when time runs out or one of the lines gets pulled down
}
if (time==timeout){ //if time ran out return -1 (error)
return -1;
}
////////////////////////////////////////////////
time=0; //reset timer
if(analogRead(A4)>200){ //if red is high
Serial.print("1");
bitSet(number,i); //the bit is one[1]
digitalWrite(3,HIGH); //R=0
while(time!=timeout){
if (analogRead(A5<200)){
break;
}
time++;
}
if (time==timeout){ //if time ran out
digitalWrite(3,LOW);
return -1;
}
////////////////////////////////////////////////
digitalWrite(3,LOW); //R=1
time=0; //reset timer
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
else
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
{
//the bit is zero[0] so no bit is set
Serial.print("0");
digitalWrite(2,HIGH); //R=0
while(time!=timeout){
if (analogRead(A4<200)){
break;
}
time++;
}
if (time==timeout){ //if time ran out return -1 (error) and R=1
digitalWrite(2,LOW);
return -1;
}
////////////////////////////////////////////////
digitalWrite(2,LOW); //R=1
time=0; //reset timer
}
}
return number;
}
void loop(){
Serial.println(IOget(2000));
delay(100);
}
When I set the state of the linkport (calc side) to either red1 white0 or white1 red0 it gives me all ones or all zero's, so there is something wrong with the confirmation signal processing.
[/code]