Bluetooth::Bluetooth(uint8_t RX, uint8_t TX, int BaudRate=38400) : serial(SoftwareSerial(RX, TX)) { // Code for set an interrupt timer in order to print // serial data available in concrete intervals in an async form. // initialize Timer1 cli(); // disable global interrupts TCCR1A = 0; // set entire TCCR1A register to 0 TCCR1B = 0; // set compare match register to desired timer count: OCR1A = 15624; // turn on CTC mode: TCCR1B |= (1 << WGM12); // Set CS10 and CS12 bits for 1024 prescaler: TCCR1B |= (1 << CS10); TCCR1B |= (1 << CS12); // enable timer compare interrupt: TIMSK1 |= (1 << OCIE1A); sei(); rx = RX; tx = TX; baudrate = BaudRate; pinMode(rx, INPUT); pinMode(tx, OUTPUT); // TODO: Check valid baud rates serial.begin(baudrate); serial.flush(); active = this; }
void Register::set(int value) { if (value != _value) { SoftwareSerial speakjet = SoftwareSerial(_rxPin, _txPin); speakjet.begin(9600); value = (value <= max_value) ? value : max_value; value = (value >= min_value) ? value : min_value; speakjet.print("\\0"); speakjet.print(_address); speakjet.print("J"); speakjet.print(value); speakjet.print("N"); speakjet.print("X"); _value = value; } }
void loop() { SoftwareSerial RFID = SoftwareSerial(rxPin,txPin); RFID.begin(RFID_SPEED); digitalWrite(LED,LOW); if((val = RFID.read()) == 10) { // check for header bytesread = 0; while(bytesread<10) { // read 10 digit code val = RFID.read(); if((val == 10)||(val == 13)) { // if header or stop bytes before the 10 digit reading break; // stop reading } code[bytesread] = val; // add the digit bytesread++; // ready to read next digit } // if 10 digit read is complete if(bytesread == 10) { strCode.clear(); strCode.append(code); if( strCode.equals(strOldCode.getChars()) ) { // nop }else{ Serial.print(code); // print the TAG code digitalWrite(LED,HIGH); strOldCode = strCode; MsTimer2::start(); // Timer start } } bytesread = 0; delay(WAIT_INTERVAL); // wait for a second } }
void SSerial_begin(long speed) { SoftwareSerial(2, 3); for(unsigned i = 0; i < sizeof(table)/sizeof(table[0]); ++i) { long baud = table[i].baud; if(baud == speed) { _rx_delay_centering = table[i].rx_delay_centering; _rx_delay_intrabit = table[i].rx_delay_intrabit; _rx_delay_stopbit = table[i].rx_delay_stopbit; _tx_delay = table[i].tx_delay; break; } } tunedDelay(_tx_delay); _buffer_overflow = false; _receive_buffer_head = _receive_buffer_tail = 0; }
// Connect the GPS Power pin to 5V // Connect the GPS Ground pin to ground // If using software serial (sketch example default): // Connect the GPS TX (transmit) pin to Digital 3 // Connect the GPS RX (receive) pin to Digital 2 // If using hardware serial (e.g. Arduino Mega): // Connect the GPS TX (transmit) pin to Arduino RX1, RX2 or RX3 // Connect the GPS RX (receive) pin to matching TX1, TX2 or TX3 // If you're using the Adafruit GPS shield, change // SoftwareSerial mySerial(3, 2); -> SoftwareSerial mySerial(8, 7); // and make sure the switch is set to SoftSerial // If using software serial, keep this line enabled // (you can change the pin numbers to match your wiring): SoftwareSerial mySerial = SoftwareSerial(3, 2); // If using hardware serial (e.g. Arduino Mega), comment out the // above SoftwareSerial line, and enable this line instead // (you can change the Serial number to match your wiring): //HardwareSerial mySerial = Serial1; Adafruit_GPS GPS = Adafruit_GPS(&mySerial); bool usingInterrupt; GpsSensor::GpsSensor() { } void GpsSensor::Init()
#define HUMID_ID "h1" //#define UPDATE_DELAY 300000 #define UPDATE_DELAY 10000 int REDPin = 9; // RED pin of the LED to PWM pin 9 int GREENPin = 11; // GREEN pin of the LED to PWM pin 11 int BLUEPin = 10; // BLUE pin of the LED to PWM pin 10 uint16_t calVal = 0; ESP8266 wifi = ESP8266(); DHT dht(DHTPIN, DHTTYPE); RGBTools rgb(REDPin, GREENPin, BLUEPin, COMMON_CATHODE); SoftwareSerial debugSerial2 = SoftwareSerial(DBG_RX_PIN, DBG_TX_PIN); bool wifiConnected = false; /* RGB LED Methods*/ void setRed() { rgb.setColor(255, 0, 0); } void setGreen() { rgb.setColor(0, 255, 0); } void setBlue() { rgb.setColor(0, 0, 255); }
#include <SoftwareSerial.h> #include <string.h> #include "Wire.h" #define rxPin 4 #define txPin 5 SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin); int i; byte res; byte msb; byte lsb; int val; void setup() { pinMode(txPin, OUTPUT); mySerial.begin(9600); Serial.begin(9600); Wire.begin(); i = 0; } void loop() { string temp; res = Wire.requestFrom(72,2); if (res == 2)
#define rxPin 6 #define txPin 7 #define ARR_LEN 8 #define TAG_LEN 12 const int DISPLAY_TIME = 100; // In milliseconds char code[20]; int val = 0; int bytesread = 0; String master_tag = "0100C1A6B3@5"; String target_tag[ARR_LEN] = { "0100C216B500" , "0100C201E567", "0100C20086K5" };//, "0100C18E89CL" }; //------------------------------------ //create a Serial object RFID SoftwareSerial RFID= SoftwareSerial(rxPin, txPin); void setup(){ Serial.begin(9600); Serial.println("Serial Ready"); RFID.begin(9600); Serial.println("RFID Ready"); pinMode(rxPin, INPUT); pinMode(txPin, OUTPUT); lcd.begin(16, 2); }
// Do not remove the include below #include "Arcade.h" #include "Button.h" #include "ButtonPad.h" #include "Joystick.h" #include "SoftwareSerial.h" Joystick* stick = new Joystick(); ButtonPad* pad = new ButtonPad(); SoftwareSerial serial = SoftwareSerial(0,1); void setup() { // TESTING serial.begin(9600); // Add Up, Down, Left, and Right to the joystick obj. stick->addDirection(0, new Button('i',STICK_UP_PIN)); stick->addDirection(1, new Button('k',STICK_DOWN_PIN)); stick->addDirection(2, new Button('j',STICK_LEFT_PIN)); stick->addDirection(3, new Button('l',STICK_RIGHT_PIN)); // Add Buttons 1-8 pad->addButton(new Button('s', BUTTON_START_PIN)); pad->addButton(new Button('S', BUTTON_SELECT_PIN)); pad->addButton(new Button('a', BUTTON_A_PIN)); pad->addButton(new Button('b', BUTTON_B_PIN)); pad->addButton(new Button('c', BUTTON_C_PIN)); pad->addButton(new Button('x', BUTTON_X_PIN)); pad->addButton(new Button('y', BUTTON_Y_PIN)); pad->addButton(new Button('z', BUTTON_Z_PIN));
////////////////////////////////////////////////////////////////////////// // servo_settings array // debounce array // hysteresis array // spectrasymbol soft pot array ////////////////////////////////////////////////////////////////////////// // variable and accessors ////////////////////////////////////////////////////////////////////////// int _led = 13; SoftwareSerial _gps = SoftwareSerial(6, 7); int led() { return _led; } SoftwareSerial& gps() { return _gps; } int read(SoftwareSerial& s) { return s.read(); } void println( SoftwareSerial& s, char* str ) { return s.println( str ); } void print( SoftwareSerial& s, char* str ) { return s.print( str );
BlinkerMac::BlinkerMac() : serial(SoftwareSerial(IR_RX_PIN, IR_TX_PIN, false)) { }
uint8_t bufferidx = 0; uint8_t fix = 0; // current fix data uint8_t i; char buffer[BUFFSIZE]; uint8_t remVTG[26] = {0xB5,0x62,0x06,0x01,0x08,0x00,0xF0,0x05,0x00,0x00,0x00,0x00,0x00,0x01,0x05,0x47,0xB5,0x62,0x06,0x01,0x02,0x00,0x0F0,0x05,0xFE,0x16}; uint8_t remRMC[26] = {0xB5,0x62,0x06,0x01,0x08,0x00,0xF0,0x04,0x00,0x00,0x00,0x00,0x00,0x01,0x04,0x40,0xB5,0x62,0x06,0x01,0x02,0x00,0xF0,0x04,0x0FD,0x15}; uint8_t remGSV[26] = {0xB5,0x62,0x06,0x01,0x08,0x00,0xF0,0x03,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x39,0xB5,0x62,0x06,0x01,0x02,0x00,0xF0,0x03,0xFC,0x14}; uint8_t remGSA[26] = {0xB5,0x62,0x06,0x01,0x08,0x00,0xF0,0x02,0x00,0x00,0x00,0x00,0x00,0x01,0x02,0x32,0xB5,0x62,0x06,0x01,0x02,0x00,0xF0,0x02,0xFB,0x13}; uint8_t remGLL[26] = {0xB5,0x62,0x06,0x01,0x08,0x00,0xF0,0x01,0x00,0x00,0x00,0x00,0x00,0x01,0x01,0x2B,0xB5,0x62,0x06,0x01,0x02,0x00,0xF0,0x01,0xFA,0x12}; uint8_t setNAV[44] = {0xB5,0x62,0x06,0x03,0x1C,0x00,0x07,0x03,0x10,0x18,0x14,0x05,0x00,0x3C,0x3C,0x14,0xE8,0x03,0x00,0x00,0x00,0x17,0xFA,0x00,0xFA,0x00,0x64,0x00,0x2C,0x01,0x0F,0x00,0x00,0x00,0x92,0x70,0xB5,0x62,0x06,0x03,0x00,0x00,0x09,0x21}; uint8_t setNAV2[56] = {0xB5,0x62,0x06,0x1A,0x28,0x00,0x07,0x00,0x00,0x00,0x03,0x04,0x10,0x02,0x50,0xC3,0x00,0x00,0x18,0x14,0x05,0x3C,0x00,0x03,0x00,0x00,0xFA,0x00,0xFA,0x00,0x64,0x00,0x2C,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x70,0x35,0xB5,0x62,0x06,0x1A,0x00,0x00,0x20,0x66}; uint8_t setNAV5[52] = {0xB5,0x62,0x06,0x24,0x24,0x00,0xFF,0xFF,0x08,0x03,0x00,0x00,0x00,0x00,0x10,0x27,0x00,0x00,0x05,0x00,0xFA,0x00,0xFA,0x00,0x64,0x00,0x2C,0x01,0x00,0x3C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x54,0x2C,0xB5,0x62,0x06,0x24,0x00,0x00,0x2A,0x84}; SoftwareSerial gpsSerial = SoftwareSerial(RX,TX); S4GPS::S4GPS() { } void S4GPS::begin(int BaudRate) { gpsSerial.begin(BaudRate); Configure(); } void S4GPS::Configure() { setupGPS(remVTG,26);
#include "RGB_Char_LCD_Backpack.h" SoftwareSerial lcd = SoftwareSerial(0,2); void lcd_begin(){ //lcd = SoftwareSerial(0,2); lcd.begin(9600); // set the size of the display if it isn't 16x2 (you only have to do this once) lcd.write(0xFE); lcd.write(0xD1); lcd.write(16); // 16 columns lcd.write(2); // 2 rows delay(10); } void lcd_setContrast(int contrast){ // set the contrast, 200 is a good place to start, adjust as desired lcd.write(0xFE); lcd.write(0x50); lcd.write(200); delay(10); } void lcd_setBrightness(int brightness){ // set the brightness - we'll max it (255 is max brightness) lcd.write(0xFE); lcd.write(0x99); lcd.write(255); delay(10); }
#include "Wire.h" #include <SoftwareSerial.h> #define microRX 5 #define microTX 4 #define buadRate 9600 #define BUFFSIZE 90 S4GPS S4GPS; bool WiFiIsOn = true; // used to turn on or off the WiFi connection char gps[BUFFSIZE]; String sensorData; SoftwareSerial microSerial = SoftwareSerial(microRX, microTX); char* deviceName; S4::S4() { } void S4::begin(char* DeviceName, char* RouterName) { deviceName = DeviceName; WDTCSR |= (1 << WDCE) | (1 << WDE); WDTCSR = 0; microSerial.begin(buadRate); // this had to be before the gps Wire.begin();
/** * Constructor */ Lcd::Lcd() { lcdPort = SoftwareSerial(LCD_RX_PIN,LCD_TX_PIN); }
char *cStatus; // Status float fLat; // Current Latitude float fLon; // Current Longitude float fVel; // Velocity float fHead; // Heading long lDate; // UTC Date float fdist; // Distance to destination float fazimuth; // Azimuth of destination from current position char *mode; // Mode char *checkSum; // Received Checksum int fSat; // Number of Satellites in use float hDop; // HDOP float fAlt; // Altitude above sea level int computedSum; // Calculated Checksum SoftwareSerial gpsSerial = SoftwareSerial(SoftrxPin, SofttxPin); dGPS::dGPS() { cont = 0; bien = 0; conta = 0; comandoGPR[0] = '$'; comandoGPR[1] = 'G'; comandoGPR[2] = 'P'; comandoGPR[3] = 'R'; comandoGPR[4] = 'M'; comandoGPR[5] = 'C'; } void dGPS::init(){
#define RFID_LENGTH 10 #define RFID_START_CHAR 0x0A #define RFID_END_CHAR 0x0D #define DEVICE_PIN 3 #define BUTTON_PIN 4 #define TIMEOUT 2000 #define SERVER_WAIT_TIME 2000 #define RESPONSE_BUFFER 400 #define COMMAND_BUFFER 400 #define STRING_BUFFER 150 char rfidCode[RFID_LENGTH+RFID_LENGTH]; unsigned long rfid_long = 0; SoftwareSerial RFID = SoftwareSerial(RFID_SERIAL_RX,RFID_SERIAL_TX); byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0x38, 0x1B }; char server[] = "dallasmakerspace.org"; IPAddress ip(192,168,1,17); byte dns1[] = {8,8,8,8}; EthernetClient client; String url = ""; String cmd = ""; enum States { WAITING, READING_RFID, TIMER_COUNTDOWN, RFID_READ, SERVER_WAIT, ERROR, DENIED}; int state = WAITING; long lastTime = 0; long timerTime = 0;
int WonLost[11]; long Abstand[11]; long Accuracy; int Status; int OldStatus; long StartTime; long RefTime; long StopTime; long ResultTime; long TimeSpan; char results[] = " "; int flag2 = 1; char userid[] = "12"; //which player are whe? SoftwareSerial myfona = SoftwareSerial(FONA_TX, FONA_RX); Adafruit_FONA fona = Adafruit_FONA(FONA_RST); void UploadResults(); void TurnOnFona(); void GetConnected(); void flushSerial(); void GetDisconnected(); void TurnOffFona(); void sleepabit(int howlong);
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ //also a replacement for gauges //set up for 2 display //also set up for 1 and bar graph display //multi mode selection via the "A" button //"B" button clears peaks and operates the usb logging as well as the timer function #define rxPin 4 #define txPin 5 SoftwareSerial LCDSerial = SoftwareSerial(rxPin, txPin); byte pinState = 0; //int logfilecount = 0; int xval = 4; int yval = 5; int negpeak = 0; int pospeak = 0; int pospeakcount = 0; int negpeakcount = 0; int zerogy = 512; int zerogx = 512; unsigned long T1 = 0; unsigned long T2 = 0;
/* * BlueTooth.cpp * * Created on: 2014.05.26. * Author: pentike */ #include "BlueTooth.h" Messenger msg = Messenger(); SoftwareSerial serial = SoftwareSerial(2, 4); void bt_command_mode() { serial.write('+'); delay(100); serial.write('+'); delay(100); serial.write('+'); delay(100); serial.write('\r'); delay(100); } void set_bt_device_name() { serial.write('A'); delay(100); serial.write('T'); delay(100); serial.write('N'); delay(100); serial.write('='); delay(100);