Teensy as a Benito

By: paul

2009-06-09 17:35:52

I released a new version of Teensyduino today, which adds USB-serial extensions to the Arduino Serial object. Now it's possible to use the Teensy via the Arduino IDE for in sorts of new ways. For example, the Teensy can be programmed to work as a Benito. Here is the simple sketch that makes it work.....
#define RESET_PIN 4
unsigned long baud = 19200;
HardwareSerial Uart = HardwareSerial();

void setup()
{
        digitalWrite(RESET_PIN, HIGH);
        pinMode(RESET_PIN, OUTPUT);
        Serial.begin(baud);   // USB, communication to PC or Mac
        Uart.begin(baud);  // UART, communication to Dorkboard
}

void loop()
{
        unsigned char c, dtr;
        static unsigned char prev_dtr = 0;

        if (Serial.baud() != baud) {
                baud = Serial.baud();
                Uart.begin(baud);
        }
        if (Serial.available()) {
                c = Serial.read();
                Uart.write(c);
        }
        if (Uart.available()) {
                c = Uart.read();
                Serial.write(c);
        }
        dtr = Serial.dtr();
        if (dtr && !prev_dtr) {
                digitalWrite(RESET_PIN, LOW);
                delay(1);
                digitalWrite(RESET_PIN, HIGH);
        }
        prev_dtr = dtr;
}

It's also possible to use this on a real Benito board. Here is a link to the HEX file, which can be loaded onto a Benito using the "DFU Loader". http://www.pjrc.com/teensy/Teensy_Benito.hex
Back to archive index