Among my several fun toys from Sparkfun's Free Day is an Arduino Duemilanove. Everyone else seems to be having fun with them as an easy-to-use microprocessor development environment for projects, so I figured I might as well jump on the bandwagon to see what all the fuss is about. I received my Sparkfun freebies today, as noted elsewhere on the Cemetech forum, so I started setting up the Arduino and seeing what programming it is like. The development environment seems pretty intuitive so far, and I like the C++ish syntax. I began by trying to interface the Thumb Slide Joystick from Sparkfun, but unfortunately the product info they had on the pinout of the device incorrect. I did some searching and debugging, and discovered the correct pinout. With the nub up and facing you, and the pins on the bottom away from you and pointing towards your chest, from left (pin 1) to right (pin 4):

1) x-axis output
2) +5V
3) y-axis output
4) gnd

Just to make sure I'm clear, my pin 4 is the one closest to the two screw/mounting holes. When connected to an Arduino, I get a range of about 128 to 775 on each axis, with enough consistency to check if it's at -x, center-x, +x, and -y, center-y, and +y. It has a fairly large range of "nominal" values when centered, but this isn't a problem for me since my application doesn't involve reading a range of values. Here's a random picture of the (very simple) testbed:



More Arduino fun coming soon.

Edit: I pulled out the control board and hardware stack for the VUFan rig out of my closet, hooked it up to the Arduino, coded a 2-minute binary counter, and voila!



Edit #2: After several hours of coding and debugging, I wrote a C++ program to read DiscoLitez-generated information off of the network and pipe it to a serial port, then an Arduino program to read in the serial data and control the fans accordingly. Video follows:



For those who missed the VUfan project the first time, here's how the very first iteration looked:

Looks like you're making rapid progress. Smile Would you say that the ease of use makes the increased cost (and irritating terminology) over a plain AVR worthwhile?
benryves wrote:
Looks like you're making rapid progress. Smile Would you say that the ease of use makes the increased cost (and irritating terminology) over a plain AVR worthwhile?
To be honest, yes, although I, like you, have gotten SO SICK of every single project on places like Hackaday using an Arduino in some sense. Last night I was working on implementing TI link routines on the Arduino; I hope to have more dependable transfers done this evening. Smile
Good to hear. I look forwards to seeing what you come up with. Smile

I think most people objected due to the relatively poor quality of the featured projects, not that they were built around an Arduino. It shouldn't matter what platform was used, as long as the result is interesting or useful!

Is it possible to use regular AVR C/assembly code with the Arduino development tools? (For example, I tried to find out of V-USB was usable with the Arduino, but all I could find were USB solutions that required an additional daughterboard - sorry, shield).
I'll begin this by saying I've never attempted to use an Arduino, but..
I believe you can at least load your own code (c/assembly/whatever) through the Arduino bootloader. Whether their tools will actively help you write/debug said code, I have no idea.

If all else fails, you can reflash the thing yourself, and maybe without a programmer if you're clever.
benryves wrote:
Good to hear. I look forwards to seeing what you come up with. Smile

I think most people objected due to the relatively poor quality of the featured projects, not that they were built around an Arduino. It shouldn't matter what platform was used, as long as the result is interesting or useful!


I think it has more to do with the fact that the Arduino is more of a "beginner's board" than say a Xilinx Spartan-3E board, so you're going to find a lot more "easy" and slightly unimaginative projects for the Arduino than you would for an FPGA platform.

benryves wrote:
Is it possible to use regular AVR C/assembly code with the Arduino development tools? (For example, I tried to find out of V-USB was usable with the Arduino, but all I could find were USB solutions that required an additional daughterboard - sorry, shield).


Yes, you can inline AVR C/assembly within an Arduino "sketch" ("source code" is too hard to say Razz)

As for the V-USB you'd have to wire a separate USB connector to the Arduino to use it because the one already on the board is attached to a FT232RL chip, which is basically just a USB -> TTL chip (but still perfectly usable with libusb).

The Tari wrote:
I'll begin this by saying I've never attempted to use an Arduino, but..
I believe you can at least load your own code (c/assembly/whatever) through the Arduino bootloader. Whether their tools will actively help you write/debug said code, I have no idea.

If all else fails, you can reflash the thing yourself, and maybe without a programmer if you're clever.


Part of the reason why I picked the Arduino; with this hack you can reprogram the ATmega328 on the board without using the Arduino bootloader.
Some more fun:

hmm, I guess I am going to have to figure out what I did with my Arduino board and start playing around with it again
rivereye wrote:
hmm, I guess I am going to have to figure out what I did with my Arduino board and start playing around with it again
Definitely! I'm afraid I got sidetracked from working on my Arduino-calculator communication (and Freebuild map development, for what it's worth) by getting a certain amount of stuff done on my thesis for my meeting this Thursday, but I hope to be able to pick it up again tomorrow.
yep, I think the minor issue though is I have an older Arduino board, the Diecimila. I don't know too much on the differences, but could be an issue trying to recreate each others projects.
rivereye wrote:
yep, I think the minor issue though is I have an older Arduino board, the Diecimila. I don't know too much on the differences, but could be an issue trying to recreate each others projects.


Basically you don't have a built-in LED on digital output pin 13 and you have an ATmega168 instead of an ATmega328; very few Arduino projects are ATmega328-only.
From the guy(s) at 4ms studio:

Sound and an LCD!

Finally got my link routines working. Here's a video of using my thumb-slide joystick to send arrow key codes to the calculator; sorry the video quality is quite poor. Code follows.




Code:
/*
    Arduino-to-TI Linking Routines
    (c) 2010 Christopher Mitchell
 */

const int TIring = 2;
const int TItip = 3;
const int xAxis = 0;
const int yAxis = 1;

const int ledb = 8;
const int ledg = 9;
const int ledr = 10;

#define TIwhite TIring
#define TIred TItip
#define ERR_READ_TIMEOUT 1000
#define ERR_WRITE_TIMEOUT 2000
#define TIMEOUT 4000
#define GET_ENTER_TIMEOUT 30000

uint8_t data[20];
void setup() {
 
   //Initialize pins
   resetLines();
   
   //debugging
   pinMode(ledr,OUTPUT);
   pinMode(ledg,OUTPUT);
   pinMode(ledb,OUTPUT);
   
   Serial.begin(115200);
}

void loop() {
   int i,j;

   resetLines();
   digitalWrite(ledr,LOW);
   digitalWrite(ledg,LOW);
   digitalWrite(ledb,LOW);
   
   i = 0;
   j = analogRead(xAxis);
   if (j < 250) i = 1;      //keyleft
   if (j > 650) i = 2;      //keyright
   j = analogRead(yAxis);
   if (j < 250) i = 4;      //keyup
   if (j > 650) i = 3;      //keydown
   if (i == 0) return;
   
   data[0] = 0x23;
   data[1] = 0x87;
   data[2] = i;
   data[3] = 0x00;
   if (0 != (i = par_put(data,4))) { Serial.print(i,DEC); Serial.println("[!]"); return; }
   Serial.print("-");
   digitalWrite(ledr,HIGH);
   if (0 == par_get(data,4)) { digitalWrite(ledg,HIGH); } else { resetLines(); }
   //for(i=0;i<3;i++) { Serial.print(data[i],HEX); Serial.print(", "); } Serial.println(data[3],HEX);
   if (data[1] != 0x56) { return; }
   if (0 == (i = par_get(data,4))) { digitalWrite(ledb,HIGH); } else { resetLines(); Serial.println(i,DEC); }
   //resetLines();
   for(i=0;i<3;i++) { Serial.print(data[i],HEX); Serial.print(", "); } Serial.println(data[3],HEX);
}

void resetLines() {
   pinMode(TIring, INPUT);           // set pin to input
   digitalWrite(TIring, HIGH);       // turn on pullup resistors
   pinMode(TItip, INPUT);            // set pin to input
   digitalWrite(TItip, HIGH);        // turn on pullup resistors
}

static int par_put(uint8_t *data, uint32_t len) {
    int bit;
    int i, j;
    long previousMillis = 0;
    uint8_t byte;   

    for(j=0;j<len;j++) {
        byte = data[j];
   for (bit = 0; bit < 8; bit++) {
            previousMillis = 0;
       while ((digitalRead(TIring)<<1 | digitalRead(TItip)) != 0x03) {
           if (previousMillis++ > TIMEOUT)
               return ERR_WRITE_TIMEOUT+j+100*bit;
            };
       if (byte & 1) {
                pinMode(TIring,OUTPUT);
                digitalWrite(TIring,LOW);
                previousMillis = 0;
      while (digitalRead(TItip) == HIGH) {
          if (previousMillis++ > TIMEOUT)
         return ERR_WRITE_TIMEOUT+10+j+100*bit;
      };
      
                resetLines();
                previousMillis = 0;
      while (digitalRead(TItip) == LOW) {
          if (previousMillis++ > TIMEOUT)
         return ERR_WRITE_TIMEOUT+20+j+100*bit;
      };
       } else {
                pinMode(TItip,OUTPUT);
                digitalWrite(TItip,LOW);      //should already be set because of the pullup resistor register
                previousMillis = 0;
      while (digitalRead(TIring) == HIGH) {
          if (previousMillis++ > TIMEOUT)
         return ERR_WRITE_TIMEOUT+30+j+100*bit;
      };
      
                resetLines();
                previousMillis = 0;
      while (digitalRead(TIring) == LOW) {
          if (previousMillis++ > TIMEOUT)
         return ERR_WRITE_TIMEOUT+40+j+100*bit;
      };
       }
       byte >>= 1;
   }
        //delayMicroseconds(6);
    }
    return 0;
}

static int par_get(uint8_t *data, uint32_t len) {
    int bit;
    int i, j;
    long previousMillis = 0;

    for(j = 0; j < len; j++) {
   uint8_t v, byteout = 0;
   for (bit = 0; bit < 8; bit++) {
       previousMillis = 0;
       while ((v = (digitalRead(TIring)<<1 | digitalRead(TItip))) == 0x03) {
      if (previousMillis++ > GET_ENTER_TIMEOUT)
          return ERR_READ_TIMEOUT+j+100*bit;
       }
       if (v == 0x01) {
      byteout = (byteout >> 1) | 0x80;
                pinMode(TItip,OUTPUT);
                digitalWrite(TItip,LOW);      //should already be set because of the pullup resistor register
                previousMillis = 0;
      while (digitalRead(TIring) == LOW) {            //wait for the other one to go low
          if (previousMillis++ > TIMEOUT)
         return ERR_READ_TIMEOUT+10+j+100*bit;
      }
                //pinMode(TIring,OUTPUT);
                digitalWrite(TIring,HIGH);
       } else {
      byteout = (byteout >> 1) & 0x7F;
                pinMode(TIring,OUTPUT);
                digitalWrite(TIring,LOW);      //should already be set because of the pullup resistor register
                previousMillis = 0;
      while (digitalRead(TItip) == LOW) {
          if (previousMillis++ > TIMEOUT)
         return ERR_READ_TIMEOUT+20+j+100*bit;
      }
                //pinMode(TItip,OUTPUT);
                digitalWrite(TItip,HIGH);
       }
            pinMode(TIring, INPUT);           // set pin to input
            digitalWrite(TIring, HIGH);       // turn on pullup resistors
            pinMode(TItip, INPUT);            // set pin to input
            digitalWrite(TItip, HIGH);        // turn on pullup resistors
   }
        data[j] = byteout;
        //delayMicroseconds(6);
    }
    return 0;
}
Cool Smile
very interesting bit of work there, mr Kerm. =]
tifreak8x wrote:
very interesting bit of work there, mr Kerm. =]
Thanks! And with that bit of fun all worked out, I will fairly painlessly be able to fake all the getKey keypresses from my remapped keyboard in translation mode, huzzah.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement