Show Posts
Pages: [1] 2 3 ... 6
1  Using Arduino / Programming Questions / Serial LCD display 6 char's expect 4 0000- 1023 on: January 30, 2014, 11:29:02 pm
This code reads the analog data being xmitted by an XBEE endpoint. That works well, I am having an issue with the sparkfun serial display. The code below outputs 6 characters I am expecting (or would like only 4) 0 to 1023.

Any helpful ideas. I'll use the XBEE lib after I get this working. smiley

Hardware xbee 1.0 end point and xbee 1.0 shield on an UNO


Code:
//xbee router
#include <SoftwareSerial.h>

;SoftwareSerial mySerial(10, 11); // RX, TX
// the setup routine runs once when you press reset:
 byte discardbyte;

int led = 13;
void setup() {
  // initialize serial communication at 9600 bits per second:
  pinMode(led, OUTPUT);
  Serial.begin(9600);
   mySerial.begin(9600);
  mySerial.write(254);
  mySerial.write(01);
  mySerial.write(254);
  mySerial.write(129);
  mySerial.print("SEN1 SEN2 SEN3");
}

void loop() {
 
  if (Serial.available()>=23){
   
    if (Serial.read()==0x7E){
     
         for (int i=1; i<15; i++){
          discardbyte = Serial.read();
   
        }
    }
       int analogLSB = Serial.read();
       int analogMSB = Serial.read();
 
int analogReading =  analogLSB + (analogMSB * 256);
     constrain(analogReading, 0, 1023);
 
     
       Serial.println(analogReading);

mySerial.write(254);
mySerial.write(193);

mySerial.print(analogReading, DEC);
//mySerial.write(254);
//mySerial.write(197);
//mySerial.write(" ");
//analogReading=0;
    }
 
}

 
2  Using Arduino / Networking, Protocols, and Devices / Making sense of XBEE rx data on: January 05, 2014, 05:24:21 pm
Code:
//xbee router
#include <SoftwareSerial.h>

;
SoftwareSerial mySerial(10, 11); // RX, TX
// the setup routine runs once when you press reset:
int led = 13;
void setup() {
  // initialize serial communication at 9600 bits per second:
  pinMode(led, OUTPUT);
  Serial.begin(9600);
}

I one have one xbee communicating to a second xbee (connected to UNO).   I am set up in API mode on the Coordinator. I am intersted in analog data on AD1 of the router.

I receive the following

0,1,2,0,3,FF,37,7E,0,A,83,0,0,42,0,1,2,0,3,FF,35,
7E,0,A,83,0,0,3D,0,1,2,0,3,FF,3A,7E,0,A,83,0,0,46,
0,1,2,0,3,FF,31,7E,0,A,83,0,0,58,0,1,2,0,3,FF,1F,
7E,0,A,83,0,0,4F,0,1,2,0,3,FF,28,7E,0,A,83,0,0,58,
0,1,2,0,3,FF,1F,7E,0,A,83,0,0,45,0,1,2,0,3,FF,32,
7E,0,A,83,0,0,58,0,1,2,0,3,FF,1F,7E,0,A,83,0,0,52,

I am expecting the analog data to be bytes 21 - 7e is the start byte

Looks like i am only getting 13 bytes.

Comments ?


---code-- here

void loop() {

  if (Serial.available()>=21){

    for (int i=1;i<22;i++){
      Serial.print(Serial.read(),HEX);
      Serial.print(",");
    }
    Serial.println();
  }
}
3  Using Arduino / Programming Questions / Re: byte no longer available in 1.0, I have a lib that uses that..... on: January 29, 2012, 11:31:12 pm
Thanks the guys at Modern Devices sent me a patch. Using 1.0.

"Byte" still an issue
4  Using Arduino / Programming Questions / Re: byte no longer available in 1.0, I have a lib that uses that..... on: January 29, 2012, 05:31:24 pm
This is the compile error I get


In file included from flux_1_29_2012.cpp:23:
C:\Users\mike\Desktop\arduino-1.0-windows\arduino-1.0\libraries\Fluxamasynth/Fluxamasynth.h:8:22: error: WProgram.h: No such file or directory
In file included from flux_1_29_2012.cpp:23:
C:\Users\mike\Desktop\arduino-1.0-windows\arduino-1.0\libraries\Fluxamasynth/Fluxamasynth.h:17: error: 'byte' has not been declared
C:\Users\mike\Desktop\arduino-1.0-windows\arduino-1.0\libraries\Fluxamasynth/Fluxamasynth.h:17: error: 'byte' has not been declared
C:\Users\mike\Desktop\arduino-1.0-windows\arduino-1.0\libraries\Fluxamasynth/Fluxamasynth.h:17: error: 'byte' has not been declared
C:\Users\mike\Desktop\arduino-1.0-windows\arduino-1.0\libraries\Fluxamasynth/Fluxamasynth.h:18: error: 'byte' has not been declared
C:\Users\mike\Desktop\arduino-1.0-windows\arduino-1.0\libraries\Fluxamasynth/Fluxamasynth.h:18: error: 'byte' has not been declared
C:\Users\mike\Desktop\arduino-1.0-windows\arduino-1.0\libraries\Fluxamasynth/Fluxamasynth.h:19: error: 'byte' has not been declared
C:\Users\mike\Desktop\arduino-1.0-windows\arduino-1.0\libraries\Fluxamasynth/Fluxamasynth.h:19: error: 'byte' has not been declared

Code:
synth.noteOn(0, a5,127);


is an example

This is the FLUXAMASYNTH documentation
"
noteOn()
Turns on (plays) the note of a specified pitch and velocity on the specified channel.
Syntax
void noteOn(byte channel, byte pitch, byte velocity);
Parameters
channel
Channel to play note (0-15).
Values greater than 15 will wrap around.
pitch
Pitch of note to turn on, in semitones (0-127).
60 = middle C (C4) = 261.63Hz. See note table.
velocity
Note attack (0-127).
On a keyboard this corresponds to how hard the key was struck.

"
I don't know how to handle this without a byte operator.
5  Using Arduino / Programming Questions / Re: Serial LCD code not working with MEGA and 1.0 on: January 29, 2012, 04:50:02 pm
Serial monitor does work, it's on comm 4 now.

The LCD works also with a simeple program on TX1.
6  Using Arduino / Programming Questions / byte no longer available in 1.0, I have a lib that uses that..... on: January 28, 2012, 10:44:40 pm
I am using a Fluxamasynth shield. It worked fine with my deomvilee. I get compile errors with the MEGA because the lib that goes with this expects byte for instance:

void setMasterVolume(byte level); //(0-255)

Any helpful suggestions?
7  Using Arduino / Programming Questions / Serial LCD code not working with MEGA and 1.0 on: January 28, 2012, 09:29:21 pm
With some difficulty I finally got my new MEGA to download and run "BLINK"  Changing to 1.0 seem to be the cure.

I am having trouble with the Sparkfun serial LCD that worked with my Deumolvilla just fine.

I am connected to TX0 on the MEGA.

Also the serial monitor doesn't seem to work right on the MEGA.

Would someone take a look please at this code. smiley-cool



Code:

/*
SerLCD - NewHaven Display Example

        Send serial data using the Serial.print() function to a Newhaven
        serial enabled display using only 3 wires. This sketch also
        introduces function declaration. You will need the datasheet
        for you display to know what the hexidecamal values are for the
        different commands used. The pinout for the NHD-0216K3Z-FL-GBW
        is as follows:
       
        RX GND VDD   SPI/I2C Connetions
         o  o  o      o  o  o  o  o  o

The circuit:
* LCD RX to Arduino TX
* LCD GND to Arduino GND
        * LCD VDD to Arduino 5V

Note: The command values are not in HEX format, they have been
              changed to there decimal equivalents.
       
        Created 24.Jan.2011
By Brandon Honeycutt - The Original Electroids Co.


*/

void setup() {
 
  // set serial baud rate
  Serial.begin(9600);
 
  // turn lcd on
  lcdOn();
 
  // set lcd contrast to default 40
  defltContrast();
 
  // clear lcd
  clearLCD();
 
  // set cursor to home
  //cHome();
 
  // set box cursor on
  bcOn();
 
  // wait 3 secs
  delay(3000);
 
}

void loop(){
 
  // print something to lcd on line one
  Serial.println("Hello Arduino");
 
  // move cursor to second line
  Serial.print(0xFE); // command flag
  Serial.print(69);   // cursor position command
  Serial.print(0x40); // cursor position
 
  // delay text printing 1 sec
  delay(2000);
 
  // print text on line two
  Serial.println("World!");
 
  delay(2000);
 
  // clear lcd
  clearLCD();
 
  delay(2000);
 
}

void clearLCD(){
 
  // clear lcd function
  Serial.print(0xFE);
  Serial.print(81);

}

void serCmd(){
 
  // command flag
  Serial.print(0xFE);
 
}

void defltContrast(){
 
  // set default contrast of 40
  Serial.print(0xFE);
  Serial.print(82);
  Serial.print(40);
 
}

void lcdOn(){
 
  // turn lcd on
  Serial.print(0xFE); // command flag
  Serial.print(65);   // on command
 
}

void cHome(){
 
  // ser cursor to home position
  Serial.print(0xFE); // command flag
  Serial.print(70);   // cursor home command
 
}

void bcOn(){
 
  // set box cursor on
  Serial.print(0xFE); // command flag
  Serial.print(75);   // cursor on command
 
}

8  Using Arduino / Programming Questions / Re: NewSoftSerial "write"? on: January 18, 2012, 09:32:15 pm
I beleive I have the latest NewSoftSerial

Error is


C:\Users\mike\Desktop\arduino-0022\libraries\NewSoftSerial/NewSoftSerial.h: In function 'void loop()':
C:\Users\mike\Desktop\arduino-0022\libraries\NewSoftSerial/NewSoftSerial.h:71: error: 'virtual void NewSoftSerial::write(uint8_t)' is private
string:382: error: within this context
string:382: error: invalid conversion from 'char*' to 'uint8_t'
string:382: error: initializing argument 1 of 'virtual void NewSoftSerial::write(uint8_t)'
9  Using Arduino / Programming Questions / NewSoftSerial "write"? on: January 18, 2012, 09:14:52 pm
I have the following code that worked with the Serial.write to my serial display:
This is a portion of the code

Code:
Serial.begin(9600);//
strcpy_P(buffer, (char*)pgm_read_word(&(string_table[instrument]))); // Necessary casts and dereferencing, just copy.
char buffer[30];    // make sure this is large enough for the largest string it must hold
Serial.write(buffer); //works on standard serial port

//Newsoft serial code
#include <NewSoftSerial.h>

Display.begin(9600);
NewSoftSerial Display(11,10); //Soft TX on 10, Idon't use RX in this code
char buffer[30];    // make sure this is large enough for the largest string it must hold
Display.write(buffer); //doesn't work

//Display.print("test"); works


What do I need to do to get NewSoftSerial to work?


10  Using Arduino / Project Guidance / Use of multiple (2) serial connections on: January 11, 2012, 01:31:33 pm
I need to use Pins 0,1 for a MIDI connection and one other pin to TX data. Should I use SoftSerial, NewSoftSerial or one
 of these and the standard comm on 0,1.  The ports do not have to be used simutaneously.
11  Using Arduino / Project Guidance / xbee on a car sensor on: December 26, 2011, 09:48:48 pm
Can xbee be used to communicate between a sensor outside of a car to an arduio in side the car?

I want to make a laser curb feeler for my low front bumper.
12  Using Arduino / Displays / Re: extra chars displayed at end on: December 24, 2011, 10:58:59 am
Thanks for the help, Serial.print worked. I will work on my posting skills for next time.
13  Using Arduino / Displays / extra chars displayed at end on: December 22, 2011, 11:27:21 pm
Code:
I am using an analog value to index through and array and display messages
on the sparkfun serial LCD

Everything works except I get extra || ||| every time

Got any ideas?


I attached some of the code, it's big.

[ftp]http://s847.photobucket.com/albums/ab37/mstadtler/
[/ftp]

/code]
prog_char string_16[] PROGMEM = "16 Dulcimer";

PROGMEM const char *string_table[] =    // change "string_table" name to suit
{
string_0,string_1,string_2,string_3,string_4,string_5,string_6,string_7,string_8,string_9,
string_10,string_11,string_12,string_13,string_14,string_15,string_16,string_17,

strcpy_P(buffer, (char*)pgm_read_word(&(string_table[instrument]))); // Necessary casts and dereferencing, just copy.
   Serial.println( buffer );
    delay( 500 );

14  Using Arduino / Project Guidance / Re: Storing 256 strings in Progmen on: December 03, 2011, 10:09:46 pm
thanks for the code . It works great!
15  Using Arduino / Project Guidance / Re: Storing 256 strings in Progmen on: December 03, 2011, 09:15:34 pm
thanks for the code . It works great!
Pages: [1] 2 3 ... 6