Paul Stoffregen Posted May 3, 2010 Posted May 3, 2010 (edited) I know this is probably old news if you're experienced with Arduino, but in case nobody mentioned it... You can use Serial.println() and Serial.print() to send messages to Arduino's "Serial Monitor". This works when you build as "USB Keyboard/Mouse" because there is a separate custom HID communication interface that sends to the Serial Monitor, completely independent of whatever you're doing with the Keyboard and Mouse. Of course, when you use a real Arduino or Teensy with USB Serial, the Arduino Serial Monitor listens to an actual COM port (windows) or serial device file (mac, linux).... and on a genuine Arduino board it actually is slow serial from the AVR chip over to a USB-Serial converter chip. On Teensy it's always native USB speed. Currently the serial monitor is broken if you're using the experimental Teensyduino USB Disk, but I'm going to fix it in alpha #3. If you've been turning the orange LED on and off to see where your code's running, making use of Serial.print() and watching with the Serial Monitor is a much more satisfying experience. Happy hacking, and please use Ducky responsibly! Edited May 3, 2010 by Paul Stoffregen Quote
NanoyMaster Posted May 3, 2010 Posted May 3, 2010 Ohhh thats awesome, I guess the Serial.print(); has some opposite option Serial.read();?!? for communication between the teensy and the comp? if not what use it it? or purley debugging? Quote
Paul Stoffregen Posted May 3, 2010 Author Posted May 3, 2010 Ohhh thats awesome, I guess the Serial.print(); has some opposite option Serial.read();?!? for communication between the teensy and the comp? if not what use it it? or purley debugging? Yes, Serial.read() and Serial.available() can be used to receive data. The usual approach looks like: if (Serial.available()) { mybyte = Serial.read(); } Serial.read() only reads a single byte, so if you want to receive strings or more than 1 byte numbers, you need to call it in a loop and parse the bytes into whatever you need. If there isn't actually a byte received, Serial.read() will return -1. If you want to wait for a byte, you need something like: while (Serial.available() < 1) { /* wait */ mybyte = Serial.read(); When using USB Serial, which is the only way you can use normal Arduino boards, these can be used to build code which communicate with PC-based code. There's lots of code out there which communicates via serial ports, because for many years (since the 1980's even), using serial communication has been the main way to communicate with microcontrollers. Over the next several months, I'm planning to add more USB types. It's a LOT of work, especially integrating them nicely into Teensyduino and making them easy to use. USB Disk still has a long way to go, as you can see from 0.9 alpha #2. Still, I'm looking for more ideas.... Joystick/Gamepad and MIDI will almost certainly be the next two, and maybe the Raw HID packet code if I can figure out ways to make it easier (more stuff on the PC side). Any other USB ideas? Quote
1n5aN1aC Posted May 3, 2010 Posted May 3, 2010 To test your code, Serial.print() is definitely the way to go, but when your running it on someone else's computer, weather for good or evil, there isn't any way to get the serial output, so a led is really the only way to do it, if you want feedback. Quote
Paul Stoffregen Posted May 3, 2010 Author Posted May 3, 2010 Ok, one LED is simpler... if you know Morse Code or something? Quote
Sl45h3R Posted May 3, 2010 Posted May 3, 2010 lol Paul, don't you think it's a bit suspicious when you plug a giant screen into someone's computer? Quote
Netshroud Posted May 3, 2010 Posted May 3, 2010 Depends on the size of the screen, and the data displayed on it. I remember I saw a USB flash drive which had a capacity indicator on it - a progress bar which ramped up as the USB drive filled up. Quote
Sl45h3R Posted May 4, 2010 Posted May 4, 2010 I suppose if you use like a 1x5 character screen, you could output "OK", or some kind of error code. Quote
BITS1 Posted July 8, 2010 Posted July 8, 2010 Over the next several months, I'm planning to add more USB types. It's a LOT of work, especially integrating them nicely into Teensyduino and making them easy to use. USB Disk still has a long way to go, as you can see from 0.9 alpha #2. Still, I'm looking for more ideas.... Joystick/Gamepad and MIDI will almost certainly be the next two, and maybe the Raw HID packet code if I can figure out ways to make it easier (more stuff on the PC side). Any other USB ideas? Can you also make teensy to be recognized as a usb wifi dongle or usb bluetooth dongle? I have seen some projects on your website that have incorporated teensy to work with bluetooth devices, joystick, in drum sets... I think they are great! :) I hope it helps. Bits1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.