noob question regarding serial

sorry for reposting but this seemed like the more appropriate section of the forum…

Hi guys, new to the forums…

anyway, I recently acquired a touch shield slide from liquidware… I was able to fire up pins and light up LED’s before the slide however I’ve made up some buttons on the slide and hope to make them fire up pins on the board… completely clueless as to how to go about this… any help is appreciated

I’ve tried reading the bitdj project on liquidware but to no luck as to what I need from there to simply light up an LED

thanks from a fledgling programmer

code to follow

just to clarify I am attempting to accept sensor data from a temp sensor as well as a compass module through I2C connected on analog in pins 2,3,4,5 at 19200 baud.

it works fine if I am only accepting sensor data.

however trying to serial write and read in order to fire up digital pin 11 is making the program hang… none of my buttons work.

is it possible to accept sensor data, display on the touchshield slide and still be able to fire up a pin (to light an led)

i have the following code snipets to share

arduino code:

#include <LibCompass.h>
#include <Wire.h>
#include <LibTemperature.h>
#include <HardwareSensor.h>
#include <SoftwareSerial.h>

#define rxPin 3
#define txPin 2

int t;
int C;
char myByte;
int eleven = 11;

SoftwareSerial mySerial = SoftwareSerial(rxPin, txPin);

LibTemperature temp = LibTemperature(0);
LibCompass compass = LibCompass(0);

void setup() {
  Sensor.begin(19200);
  Serial.begin(9600);
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  pinMode(eleven, OUTPUT);
  mySerial.begin(9600);
}

void loop(){
t = (int)temp.GetTemperature();
Sensor.print("temp", t);
C = (int)compass.GetHeading();
sensor.print("compass", C);


    myByte = mySerial.read();
      if(myByte == 'A') //if the letter "A" comes from the touchshield
      {
      digitalWrite(eleven, HIGH);
      } 
      if(myByte == 'B') //if the letter "B" comes from the touchshield
      {
      digitalWrite(eleven, LOW);
      }
delay(5);
}

and code for the touch shield slide

#include <BarGraph.h>
#include <HardwareSensor.h>
#include <TButton.h>

TButton tempf = TButton("Temp in F",20,20);
TButton tempc = TButton("Temp in C ",120,20);
TButton compass = TButton(" Compass ",220,20);
TButton back = TButton("  return  ",120,80);
TButton doorlock = TButton("   locks  ",200 , 80);
TButton doorunlock = TButton("   unlock  ",200 , 140);
TButton windowup = TButton("window up", 20 , 80);  
TButton windowdown = TButton("window down", 20 , 140);

int state = 0;
int t;
int C;
int newT;
char tempstr[5];
char tempstr2[5];




void setup() 
{
  Sensor.begin(19200);
  Serial.begin(9600);
  background(0);
  tempf.Paint();
  tempc.Paint();
  compass.Paint();
  doorlock.Paint();
  doorunlock.Paint();
  windowup.Paint();
  windowdown.Paint();
   
}

void drawNumber(int number, int xPos, int yPos) {
  int counter;
  int16_t h,t,o;

    h = number / 100;
    t = (number - (h*100) ) / 10;
    o = number - (h*100) - (t*10);
    stroke(255);
    fill(0);
    if (h){
       Display7SegmentDigit(xPos,yPos,h,25);
    }
    if (t) {
    Display7SegmentDigit(xPos+32,yPos,t,25);
    }
    Display7SegmentDigit(xPos+32+32,yPos,o,25); 
}

void loop() 
{

  if (Sensor.available()) 
  {

    if (!strcmp(Sensor.getName(), "temp")) 
    { 
      t = Sensor.read();
      //convert celcius to fahrenheit
      newT = (t*1.8 + 32);
    }

    if(!strcmp(Sensor.getName(), "compass")) 
    { 
      C = Sensor.read();
  
    }
  }
  
  if (tempf.GetTouch())
  {
    background(0);
    stroke(255);
    fill(0);
    back.Paint();
    text("Temperature in F:", 5, 150,10);
    state = 1;
    
  }
  
  if (tempc.GetTouch())
  {
    background(0);
    stroke(255);
    fill(0);
    back.Paint();
    text("Temperature in C:", 5, 150,10);
    state = 2;
    
  }
  
  if (compass.GetTouch())
  {
    
    background(0);
    stroke(255);
    fill(0);
    back.Paint();
    text("Heading:", 5, 150,10);
    state = 3;
  }
  
  if (Sensor.available() && state == 1)
    { 
      if (!strcmp(Sensor.getName(), "temp")) 
      drawNumber(newT, 200, 150);
    }
   if (Sensor.available() && state == 2)
    { 
      if (!strcmp(Sensor.getName(), "temp")) 
      { 
        t = Sensor.read();
      }
      drawNumber(t, 200, 150);
      //delay(0); 
    } 


    if (Sensor.available() && state == 3) 
    {
    if(!strcmp(Sensor.getName(), "compass")) 
    { 
       C = Sensor.read();
       
    
      
      
    if(C >= 0.00 && C < 23.00)
    {
      //print the compass heading

      
      compass.Paint();
      back.Paint();
      stroke(255);
      fill(0,0,255);
      rect(150,135,45,30); //draw the rectangle
      fill(0); 
      text("Heading:", 5, 150,10);
      state = 3;
      fill(0);
      text("N ", 160, 150, 18); 
      
      
    }

    if(C >= 23.00 && C < 68.00)
    {
      compass.Paint();
      back.Paint();
      stroke(255);
      fill(0,0,255);
      rect(150,135,45,30); //draw the rectangle
      fill(0); 
      text("Heading:", 5, 150,10);
      state = 3;
      fill(0);
      text("NE", 160, 150, 18); 

     }

   if(C >= 68.00 && C < 113.00)
    {
      compass.Paint();
      back.Paint();
      stroke(255);
      fill(0,0,255);
      rect(150,135,45,30); //draw the rectangle
      fill(0); 
      text("Heading:", 5, 150,10);
      state = 3;
      fill(0);
      text("E ", 160, 150, 18); 
    }

     if(C >= 113.00 && C < 158.00)
     {
                  compass.Paint();
      back.Paint();
      stroke(255);
      fill(0,0,255);
      rect(150,135,45,30); //draw the rectangle
      fill(0); 
      text("Heading:", 5, 150,10);
      state = 3;
      fill(0);
      text("SE", 160, 150, 18); 
     }

     if(C >= 158.00 && C < 203.00)
     {
           compass.Paint();
      back.Paint();
      stroke(255);
      fill(0,0,255);
      rect(150,135,45,30); //draw the rectangle
      fill(0); 
      text("Heading:", 5, 150,10);
      state = 3;
      fill(0);
      text("S ", 160, 150, 18); 
     }

     if(C >= 203.00 && C < 248.00)
     {
            compass.Paint();
      back.Paint();
      stroke(255);
      fill(0,0,255);
      rect(150,135,45,30); //draw the rectangle
      fill(0); 
      text("Heading:", 5, 150,10);
      state = 3;
      fill(0);
      text("SW", 160, 150, 18); 
     }
 
     if(C >= 248.00 && C < 293.00)
     {
  
                    compass.Paint();
      back.Paint();
      stroke(255);
      fill(0,0,255);
      rect(150,135,45,30); //draw the rectangle
      fill(0); 
      text("Heading:", 5, 150,10);
      state = 3;
      fill(0);
      text("W ", 160, 150, 18); 
      }

     if(C >= 293.00 && C < 338.00)
     {
                    compass.Paint();
      back.Paint();
      stroke(255);
      fill(0,0,255);
      rect(150,135,45,30); //draw the rectangle
      fill(0); 
      text("Heading:", 5, 150,10);
      state = 3;
      fill(0);
      text("NW", 160, 150, 18); 
     }
 
     if(C >= 338.00 && C < 360.00)
     {
                    compass.Paint();
      back.Paint();
      stroke(255);
      fill(0,0,255);
      rect(150,135,45,30); //draw the rectangle
      fill(0); 
      text("Heading:", 5, 150,10);
      state = 3;
      fill(0);
      text("N", 160, 150, 18); 
     }
   }
     
}

 if (back.GetTouch()) 
 {
  background(0);
  tempf.Paint();
  tempc.Paint();
  compass.Paint();
  doorlock.Paint();
  doorunlock.Paint();
  windowup.Paint();
  windowdown.Paint();
  state = 0;
 }
 
  if (doorlock.GetTouch()) 
 {
   Serial.print('A');
   delay(800);
   Serial.print('B');
 }
 


}

I’ve tried having the sensors at 19200 and the regular serial at 9600 and i’ve also tried having them both at 19200 for example I tried:

sensor.begin(19200)
serial.begin(19200)

and:
sensor.begin(19200)
serial.begin(9600)

and:
sensor.begin(9600)
serial.begin(9600)

but I can’t get both my sensors and my button to turn on the LED to work at the same time.

any help is appreciated.

thank you!

First remark: SoftSerial is superseded by NewSoftSerial, please rewrite your code with NSS as it is more stable see http://sundial.org/arduino/index.php/newsoftserial/

thank you for the response.

I've imported the library, included it in the program... replaced all instances of softserial with NSoftSerial but to no avail...

now program won't compile at all....

please see error messages:

Handling the compile 11
Saving sketches...
Sketches saved.
compile(), new thread run about to sketch.compile()
     [echo] Building Arduino Duemilanove or Nano w/ ATmega328 libraries...
     [echo] Building Arduino Duemilanove or Nano w/ ATmega328 board target...
     [echo] Building A2D_temp_Comp for the Arduino Duemilanove or Nano w/ ATmega328 core...
     [exec] C:\Users\Paolo\AppData\Local\Temp\build7395474851757950285.tmp/targets/body/lib\libcontrib.a(AFSoftSerial.o): In function `whackDelay':
     [exec] C:\Users\Paolo\Desktop\SD2\hardware\arduino\cores\arduino\src\components\libraries\AFSoftSerial/AFSoftSerial.cpp:54: multiple definition of `whackDelay(unsigned int)'
     [exec] C:\Users\Paolo\AppData\Local\Temp\build7395474851757950285.tmp/targets/body/lib\libcontrib.a(NSoftSerial.o):C:\Users\Paolo\Desktop\SD2\hardware\arduino\cores\arduino\src\components\libraries\NSoftSerial/NSoftSerial.cpp:52: first defined here
     [exec] C:\Users\Paolo\AppData\Local\Temp\build7395474851757950285.tmp/targets/body/lib\libcontrib.a(AFSoftSerial.o): In function `SIG_PIN_CHANGE2':
     [exec] C:\Users\Paolo\Desktop\SD2\hardware\arduino\cores\arduino\src\components\libraries\AFSoftSerial/AFSoftSerial.cpp:67: multiple definition of `SIG_PIN_CHANGE2'
     [exec] C:\Users\Paolo\AppData\Local\Temp\build7395474851757950285.tmp/targets/body/lib\libcontrib.a(NSoftSerial.o):C:\Users\Paolo\Desktop\SD2\hardware\arduino\cores\arduino\src\components\libraries\NSoftSerial/NSoftSerial.cpp:66: first defined here
     [exec] C:\Users\Paolo\AppData\Local\Temp\build7395474851757950285.tmp/targets/body/lib\libcontrib.a(AFSoftSerial.o): In function `SIG_PIN_CHANGE0':
     [exec] C:\Users\Paolo\Desktop\SD2\hardware\arduino\cores\arduino\src\components\libraries\AFSoftSerial/AFSoftSerial.cpp:62: multiple definition of `SIG_PIN_CHANGE0'
     [exec] C:\Users\Paolo\AppData\Local\Temp\build7395474851757950285.tmp/targets/body/lib\libcontrib.a(NSoftSerial.o):C:\Users\Paolo\Desktop\SD2\hardware\arduino\cores\arduino\src\components\libraries\NSoftSerial/NSoftSerial.cpp:60: first defined here


BUILD FAILED
C:\Users\Paolo\Desktop\SD2\hardware\arduino\cores\arduino\build.xml:136: The following error occurred while executing this line:
C:\Users\Paolo\Desktop\SD2\hardware\arduino\cores\arduino\src\template\build.xml:154: The following error occurred while executing this line:
C:\Users\Paolo\Desktop\SD2\hardware\arduino\cores\arduino\config\build.ccmacros.xml:45: exec returned: 1

Total time: 12 seconds

Have you restarted the IDE? and placed the library in the right place? See http://arduino.cc/en/Reference/Libraries ?

Sounds like there is some old SoftSerial include somewhere?

I've replaced all references to softserial with the new one in the other libraries...

Any other tips?

Anything glaringly obvious in my code?

Thanks so much for the help!