Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - adept

Pages: [1]
1
Other / Re: TI-Nterface (my version of labpro)
« on: February 18, 2012, 03:05:24 pm »
I, and many others, including you Keoni, have been wanting to interface the calculators serial with an Arduino. I've coded only sparsely in my life, just enough to get by. I use lots of example code to write programs, they're my crutch. So basically what I have right now is a Arduino program that sends a byte repeatedly through the link port using Kerm Martian's whitepaper on the Calcnet protocol to fix my timings. But the calc still receives nothing. I am using two programs on the calc to receive a byte. The built in GET command and my Omnicalc linkreceive() command. Neither of these get anything from my program on the Arduino. Here is my code:

Code: [Select]
#include <SPI.h>

int Data = 6; //Data or TIP or RED
int Clock = 7; //Clock or RING or WHITE
byte DRead = 0;
byte DataByte = 0;

void setup()
{
  Serial.begin(9600);
  delay(1000);
  Serial.println("Awesome Sauce! :)");
}

void loop()
{
  sendByte(127);
}

int sendByte(byte DataByte)
{
  //initialize the contact with the mothership

  pinMode(Data, OUTPUT);
  pinMode(Clock, OUTPUT);
  digitalWrite(Data, HIGH);
  digitalWrite(Clock, HIGH);
  delayMicroseconds(1000);
  digitalWrite(Clock, LOW);
  delayMicroseconds(9000);
  digitalWrite(Data, HIGH);
  digitalWrite(Clock, HIGH);
  delayMicroseconds(52);
  delayMicroseconds(110);
  digitalWrite(Data, LOW);
  digitalWrite(Clock, LOW);
  delayMicroseconds(52);
  digitalWrite(Data, HIGH);
  digitalWrite(Clock, HIGH);
  delayMicroseconds(42);

  //send data now
  int BitIncrement;
  for(BitIncrement<=7; BitIncrement++;)
  {
  int SendBit;
  bitRead(DataByte, BitIncrement);
  digitalWrite(Data, SendBit);
  delayMicroseconds(17);
  digitalWrite(Clock, LOW);
  delayMicroseconds(35);
  digitalWrite(Data, HIGH);
  digitalWrite(Clock, HIGH);
  delayMicroseconds(52); 
  }
}

int recieveByte(void)
{
  //initialize contact with the daughtership
 
  pinMode(Data, INPUT);
  pinMode(Clock, INPUT);
  DRead = digitalRead(Data);
  return DRead;
}

Pages: [1]