Version 1.0 of the Arduino software includes an update to the SoftwareSerial library, which (among other things) can output inverted-TTL serial that works with our BPI-, BPK-, and BPP- series devices. The example sketch is after the break.
Hookup
In the pic at right (click to enlarge), a
BPI-216L is connected to an Arduino Uno via a BSW-CBL wiring harness (a worthwhile option when you're buying the display). Connections are
- Red: Arduino 5V to BPI +5
- Black: Arduino GND to BPI GND
- White: Arduino 3 to BPI SER
If you want to use a different Arduino pin for serial output, you can change the 3 in
#define txPin 3
to the desired pin number.
/*This program uses the updated SoftwareSerial distributed in v1.0 of
the Arduino software. Users of earlier versions must download
NewSoftSerial. */
#include <SoftwareSerial.h>
#define rxPin 255 // Not used, so set to invalid pin #
#define txPin 3 // Connect BPI/BPK's SER input to this pin.
#define inverted 1 // In setup, 1=inverted, 0=noninverted
const char clearScreen[ ] = {
254,1,254,128,0};
const char message[ ] = "Hello World!" ;
/*
Set up a new serial output using the pin definitions above. Note the
argument "inverted," which instructs SoftwareSerial to output BPI/BPK-
compatible inverted-TTL serial (like RS-232, but without the +/-
voltage swing).*/
SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin, inverted);
void setup() {
// define pin mode for tx:
digitalWrite(txPin, LOW); // Stop bit state for inverted serial
pinMode(txPin, OUTPUT);
mySerial.begin(9600); // Set the data rate
delay(10); // wait (may not be needed w/ Arduino v1.0)
mySerial.print(clearScreen);
mySerial.print(message);
}
void loop() {
// ...
}
Hey thanks a bunch for this tip! Got an old SEE display going with my Arduino and I can still use the display with my BS-2 when necessary! Thanks again.
ReplyDeleteAl
Muchas gracias!!!
ReplyDelete