Newsoftserial BYTE keyword not supported in 1.0

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
jones7625
 
Posts: 1
Joined: Sun Dec 11, 2011 9:28 am

Newsoftserial BYTE keyword not supported in 1.0

Post by jones7625 »

I need help getting already working Arduino 22 Newsoftserial code to work in 1.0. When compiling, the error message I receive is: "As of Arduino 1.0, the 'BYTE' keyword is no longer supported. Please use Serial.write() instead."

I'm guessing using the Serial.write function then makes me use the hardward serial pins which is what I want to avoid.

Code: Select all

#include <NewSoftSerial.h>
NewSoftSerial softSerial(4,5); // 4 is the rx and 5 the tx
int target = 0;  
byte serialBytes[2]; // declare an array for the speed command
void setup()
{
  softSerial.begin(9600);
  pinMode(4, INPUT);
  pinMode(5, OUTPUT);
}
void loop()
{
  while(target < 4000){
    serialBytes[0] =  0xC0 + ( target & 0x1F);    // Command byte holds the lower 5 bits of target.  
    serialBytes[1] =  (target >> 5) & 0x7F;       // Data byte holds the upper 7 bits of target.  
    //Send a Pololu JRK21v3 Protocol command
    softSerial.print(0xAA,BYTE);                  //start byte
    softSerial.print(0x0B,BYTE);                  //device id - default is 11
    softSerial.print(0x40,BYTE);                  //command 40 is Set Target High Resolution
    softSerial.print(serialBytes[0], BYTE);       //speed
    softSerial.print(serialBytes[1], BYTE);       //speed 
    target = target + 1000;
    delay(5000);
  }
  target = 0;
}

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: Newsoftserial BYTE keyword not supported in 1.0

Post by adafruit_support_bill »

You can use softSerial.write().

User avatar
floresta
 
Posts: 223
Joined: Thu Jul 31, 2008 10:27 am

Re: Newsoftserial BYTE keyword not supported in 1.0

Post by floresta »

I'm guessing using the Serial.write function then makes me use the hardward serial pins which is what I want to avoid.
No, that's not what will happen.

#include <NewSoftSerial.h>
Here you told the compiler that you are going to use functions found in the NewSoftSerial library

NewSoftSerial softSerial(4,5); // 4 is the rx and 5 the tx
Here you told the compiler two things
(a) that you are going to use the term 'softSerial' to identify those functions that the compiler is to get from the NewSoftSerial library
(b) that you are going to use Arduino pin 4 for Rx and Arduino pin 5 for Tx

Don

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”