Show Posts
Pages: [1]
1  Forum 2005-2010 (read only) / Interfacing / Re: 7 Segment Display with NewSoftSerial on: October 18, 2009, 03:10:17 pm
I think you have your Serial and mySerial switched. mySerial is what you are using to print to the SFE Serial LED, attached to pin 3 in your example.

Your code was:
Code:
void loop()
{
Serial.write(0x01);
Serial.write(0x04);
Serial.write(0x02);
Serial.write(0x00);
Serial.println(" ");
}


Try this instead:
Code:
void loop()
{
mySerial.print(0x01);
mySerial.print(0x04);
mySerial.print(0x02);
mySerial.print(0x00);
}

Note: ONLY send 4 numbers to the SFE LED. You had a Serial.println(" "); in your code after printing 4 numbers. Don't do that.

Hope this helps.
2  Forum 2005-2010 (read only) / Interfacing / Re: 7 Segment Display with NewSoftSerial on: September 06, 2009, 02:55:40 pm
I used digital pin 3, not analog pin 3. The analog pins can also be used as digital input pins: analog 0 through 5 are digital 14 through 19.

See http://www.arduino.cc/en/Tutorial/AnalogInputPins for more information.

You can use analog pin 3 if you want, but you have to refer to it as digital pin 17.

Hope this helps....
3  Forum 2005-2010 (read only) / Interfacing / 7 Segment Display with NewSoftSerial on: August 05, 2009, 09:32:30 pm
This is a follow-up to a post in the 7 Segment Display with SPI (different thread): http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1247533060/2#2. I'm starting a new thread in case people wanted to see how to use the TTL Serial input side of the SparkFun LED Serial Breakout Board (http://www.sparkfun.com/commerce/product_info.php?products_id=9230).

Wiring is easy, GND, Vcc and Rx from pin 3 of arduino. Code is also easy, just send Serial.print statements, or mySerial.print statements in this example. Remember to send four print statements to fill out all four digits in the display, see the SFE docs for details.

Hint: for controlling the output, the ASCII Table is your friend - http://www.asciitable.com/

The code example is for an XBee temperature monitor receiving module. I wanted to be able to print the temps out with Serial.print statements and also send the temps to the LED display via mySerial.print statements.

Not the best code in the world, and if you have helpful hints, they're appreciated. Be gentle, I'm a noob.

Code:
// NOTES:
// Using SparkFun Serial LED with XBee receiver
//      2009-08-03

#include <NewSoftSerial.h>

NewSoftSerial mySerial(2, 3);      // Tx from arduino is pin 3, connect to Rx on SFE LED Serial


// following variables for receiving XBee Serial info and displaying them
byte incomingByte;
int j =0;
int prtout = 0;            // flag to know when to send to LED display
int digitcnt = 0;      // count the number of digits in incoming temperature
char temps[5];          // temperature array

void setup() {
  
// start serial port at 9600 bps
Serial.begin(9600);
Serial.println("Ready!");
 mySerial.begin(9600);

delay(1000);

}


void loop()
{  
j =0;
prtout =0;      // don't print out until set to 1, then turn off flag immediately
digitcnt = 0;   // count the number of digits of temperature for later use with index j

// Note: Sending XBee transmits temperature in degrees F, terminated by CR and LF (Serial.println(mytemp) on sending XBee)
//      Need to remove the CR/LF or not send it to LED digits


while(Serial.available())       // are there any bytes available on the serial port ???
{  
prtout =1;                          // if bytes available set flag to print them later
incomingByte = Serial.read();        // NOTE: value for temp PLUS CR and LF included in read, see above
temps[j]=(byte(incomingByte));       // store the temperature digits in an array
Serial.print(temps[j]);
j++;
delay(200);                  // achieved experimentally - need some kind of delay between iterations to receive properly
}


if (prtout)
{  
  digitcnt = j-2;       // digitcnt holds the highest used index value for temp digits + 1 for use as conditional stop statement, ignore CR and LF
      if (digitcnt == 3)
      { mySerial.print("x");}
      if (digitcnt == 2)
      { mySerial.print("x");
        mySerial.print("x");}
    for(j=0;j < digitcnt;j++)    
        {Serial.print(temps[j]);   // now print temperature values left-to-right, but right-justified
        mySerial.print(temps[j]);  
        }
  Serial.println(" ");
    
 prtout = 0;
}

 
}
4  Forum 2005-2010 (read only) / Interfacing / Re: 7 Segment Display using SPI on: June 20, 2010, 09:33:36 am
@2xyo - These 7 segment displays have two physical interfaces. This topic thread is about SPI, and you're trying to use the Serial interface.

See the thread at: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1249525950/2 about using Serial with this display. Working code is shown in that thread.
5  Forum 2005-2010 (read only) / Interfacing / Re: Sparkfun SerLCD Control Codes... on: May 07, 2008, 11:07:32 pm
This may be slightly off topic, but I'm adding it here in the hopes of helping someone out in the future.

I have also had problems with the SF SerLCD, but probably of my own making. I uploaded a sketch while I had the LCD connected and lost the second line of the display. I tried several variants of the code supplied by sti robot but could not get the "Reset to 9600 Baud" message to display, or the second line to resurrect itself. Finally, I used the following and it reset and the second line will display now. Note that I am NOT sending the 0x7c (124) control character in the sketch, but it seems to work anyway!?!


Code:
//resets the serial LCD to its factory Two Line settings
//Leave power to the LCD unplugged and USB to the LCD plugged in
//Upload the program, pull the USB, then reconnect USB
//Connect power, GND and RX
//Should see "Reset to 9600 Baud" followed by square dots
//now on both lines

void setup(){
 Serial.begin(9600);
}

void loop(){
 //Serial.print(0x7C, BYTE);  //special character
 Serial.print(18, BYTE); // Reset to 9600 Baud
 Serial.print(6, BYTE);  //Reset character for 2 Lines on LCD
 
 delay(50);
}


6  Forum 2005-2010 (read only) / Exhibition / Re: camera shutter tester on: May 13, 2009, 05:01:02 pm
That is beautiful - simple, useful and elegant. I see you have :
duration = pulseIn(receiverPin, LOW);
So, does that mean the IR detector is normally HIGH and pulls LOW when IR is present?
I didn't see that mentioned in the docs.
Pages: [1]