[McHUG] Serial for debugging Arduino code
Peter Morton
mortonph at comcast.net
Tue Nov 4 15:49:12 EST 2008
Rich-
Is the WIRE library part of the Arduino IDE or must it be downloaded from
somewhere?
-Pete, W3GVX
----- Original Message -----
From: "Rich Mitchell" <geobra at att.net>
To: "McHUG Reflector" <mchug at mailman.qth.net>
Sent: Tuesday, November 04, 2008 12:19 PM
Subject: [McHUG] Serial for debugging Arduino code
> McHUGgers,
> I have been trying to convert Pete's Si570 code into an Arduino sketch
> using the Wire library (TWI, I2C), so far without much success. But along
> the way I have discovered a good way to debug. Use Serial that's already
> part of Arduino, no library to include, initialize Serial in setup() and
> write out statements and variables to your Serial console from the loop().
> If you are already using your serial cable and P4 to upload code to the
> Arduino, there is no additional hardware setup. All you have to do is
> turn on Arduino's serial monitor (once you have uploaded the sketch) and
> watch the statements come back. I'm copyiing in the sketch for Blink and
> adding Serial debugging statements that tell you if the led should be on
> or off. This should work okay, but I haven't got back to my Arduino
> environment to test it.
>
> /* Blinking LED
> * ------------
> *
> * turns on and off a light emitting diode(LED) connected to a digital
> * pin, in intervals of 2 seconds. Ideally we use pin 13 on the Arduino
> * board because it has a resistor attached to it, needing only an LED
> *
> * Created 1 June 2005
> * copyleft 2005 DojoDave <http://www.0j0.org>
> * http://arduino.berlios.de
> *
> * based on an orginal by H. Barragan for the Wiring i/o board
> */
> int ledPin = 13; // LED connected to digital pin 13
> void setup()
> {
> pinMode(ledPin, OUTPUT); // sets the digital pin as output
> Serial.begin(9600); // initialize Serial to 9600 baud.
> }
> void loop()
> {
> digitalWrite(ledPin, HIGH); // sets the LED on
> Serial.print("Pin "); // send a string using print
> Serial.print(ledPin); // send a variable using print
> Serial.println(" is on."); // send string and CRLF with println
> delay(1000); // waits for a second
> digitalWrite(ledPin, LOW); // sets the LED off
> Serial.print("Pin "); // send a string using print
> Serial.print(ledPin); // send a variable using print
> Serial.println(" is off."); // send string and CRLF with println
> delay(1000); // waits for a second
> }
>
>
> I've been using Serial.println() to see how far I'm getting in the Si570
> sketch - which compiles fine. When it tries to read reg 137, it just
> hangs. The Si570 chip starts a tone at 7.075 MHz which may be a default.
> Anyway, the Serial class is a big help in debugging.
>
> Rich, N3III
> --
> McHUG - Physical Computing ;)
> MicroController Ham User Group
>
> ______________________________________________________________
> McHUG mailing list
> Home: http://mailman.qth.net/mailman/listinfo/mchug
> Help: http://mailman.qth.net/mmmain.htm
> Post: mailto:McHUG at mailman.qth.net
More information about the McHUG
mailing list