Show Posts
Pages: 1 ... 7 8 [9] 10 11 ... 14
121  Using Arduino / Programming Questions / I can't understand why one works but not the other on: April 05, 2012, 01:06:57 pm
I tried to use "save for forum" but have no idea what name it saves under or where it's saved. This works:

char message[200];

void setup()
{
   Serial.begin(9600);   //Set up serial wireless           
   Serial1.begin(9600);   //Set up serial wireless           
   Serial.flush();
}

void loop()
{
  int i=0;
  if (Serial1.available() >= 0) // is there data from other unit?
   {
     while( Serial1.available() && i< 99)
     {
        message[i++] = Serial1.read(); // read rest of message into string
     }
     message[i++]='\0'; // end with new line
      Serial.print(message);
   }
}
   
This prints the line:

Temperature: xxFHumidity: xx% or
Temperature: -xxFHumidity: xx%

This doesn't:

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

char * message ;
char * Tmessage;
char * Hmessage;
char * temp;
LiquidCrystal_I2C lcd(0x27,20,4); //set the LCD address to 0x27 for a 16 chars and 2 line display

void setup()
{
   Serial.begin(9600);   //Set up serial wireless           
   Serial1.begin(9600);  //Set up APC220 wireless           
   Serial.flush();
   lcd.init();
   lcd.backlight();
   lcd.setCursor(0, 0);
int m = 0;
int T = 0;
int H = 0;
  if (Serial1.available() >= 0) // is there data from other unit?
   {
     while( Serial1.available() && m < 99)
        message[m++] = Serial1.read(); // read rest of message into string;
     }
        message[m++] = '\0';
     Serial.print(message);
     m = 0;
   while ( temp[0] != 'F')
   {
      temp
  • = message[m++];
      Tmessage[T++] = temp[0];   
   }
   while( temp[0] != '%')
   {
      temp
  • = message[m++];
      Hmessage[H++] = temp[0];   
   }
      Tmessage[T++] = '\0';   
      Hmessage[T++] = '\0';   
     Serial.println(Tmessage);
     Serial.println(Hmessage);     
     lcd.println(Tmessage);
     lcd.println(Hmessage);     
   }
}

void loop()
{
     delay (100);
}


All that prints are two garbage characters. I'm trying to separate a received string of the format
Temperature: xxFHumidity: xx% or
Temperature: -xxFHumidity: xx%

to 2 strings

Temperature: (-)xxF
Humidity: xx%

Instead all I get is two garbage characters total

Jim
122  Development / Suggestions for the Arduino Project / Re: Making the com port only for the particular instance of the IDE on: March 31, 2012, 04:20:54 pm
Nick Gammon said
Did you start multiple instances of the IDE? Or just multiple windows? I started two instances and could set one to COM1 and one to COM2. Not that I tried plugging the board in.
Right on Nick, I had not known that starting new windows from the IDE did not start a new instance. It was not readily apparent that that was what was happening. That was exactly what I was doing. Boy, that is going to save me many headaches! Thanks a bunch!

Grumpy_Mike, I don't think I'll ever get THAT high.
123  Using Arduino / Displays / Re: Sending a "newline" to an I2c 20x4 lcd on: March 31, 2012, 04:05:34 pm
I implemenmted Graynomad's code, it half worked. Now I get:

T|| |||
H|| |||

on the LCD. Obviously it does not respond like a serial device.

bperrybap, how about -29F(-34C), I've seen that here. Actually, if it is below 20F(-7C), I not going out there anyway. Seriously though, how do I get that string.h into the ICD? I would prefer making my program as flexible as possible.

Thanks for the reply!

Jim
124  Development / Suggestions for the Arduino Project / Making the com port only for the particular instance of the IDE on: March 31, 2012, 02:42:50 pm
I am currently working on a project with 3 Arduinos(for now, more to come). I have the Arduino IDE up for each Arduino. Every time I switch from one Arduino to another I have to change the com port because it is common to all instances. It would be nice if each instance of the IDE could have it's own com port. Also I'm up to com 11, how many com ports does the IDE support?

Jim
125  Using Arduino / Displays / Re: Sending a "newline" to an I2c 20x4 lcd on: March 31, 2012, 02:30:07 pm
To Graynomad

The string could be possibly be:

"Temperature: xx.xxC Humidity: xx%"
              or
"Temperature: xxx.xxC Humidity: xx%"

depending on the temperature. However, as I live at 6000 feet(1900 meters), I don't think it's too likely, so I'll use your provided code. I am an old VB programmer, and don't know using pointers that well, I'm used to VB's string functions.

THANKS A LOT
Jim
126  Using Arduino / Displays / Sending a "newline" to an I2c 20x4 lcd on: March 30, 2012, 05:21:16 pm
I am transmitting temperature/humidity via an Apc220 to an Arduino with a 20x4 I2C LCD. The text being received as a single string, and is "Temperature: xx.xxC Humidity: xx%". What i am getting on the LCD is:
---------------------
Temperature: xx.xxCH

umidity: xx%

-----------------------

I need to insert a newline char between the C and H,in the transmitted signal, to put humidity on it's own line. I also need to eliminate the extra blank line in between temperature and humidity. I've tried all the newline characters I can figure out but have not found any that work. Is there an easy to separate the string into 2 smaller strings at the CH boundary? Then I could send the LCD to line 1,0 and the humidity line should fit.

Jim
127  Development / Suggestions for the Arduino Project / I need a Timer# library, does one exist on: March 08, 2012, 02:23:11 pm
I have an Arduino 2560 with a series of sensors.
I want to transmit the values of these sensors
via a rf module ( APC220 ), at approximately
every 10 seconds. I have written a function to do this
when called. I want to use timer 4 to call this function.
The more I search  on the web, the more confused I get.
The timer2 library makes it easy but seems only for timer 2
which as I understand the example, does not extend
to near enough time. Is there a generic timer library
which allows you to use any timer? I looked at the code for timer2
and this is way past my meager knowledge. I would such a library
would be useful to many.
Jim
128  Using Arduino / Installation & Troubleshooting / Is there a Timer#n library on: March 06, 2012, 05:44:50 pm
I have an Arduino 2560 with a series of sensors.
I want to transmit the values of these sensors
via a rf module ( APC220 ), at approximately
every 10 seconds. I have written a function to do this
when called. I want to use timer 3 to call this function.
The more I search  on the web, the more confused I get.
The timer2 library makes it easy but seems only for timer 2
which as I understand the example, does not extend
to near enough time. Is there a generic timer library
which allows you to use any timer?
Jim
129  Using Arduino / Networking, Protocols, and Devices / Re: Confusing response with APC220 solved by workaround on: March 05, 2012, 04:50:32 pm
Having not received any responses, I found a way to work around this issue.
jim
130  Using Arduino / Installation & Troubleshooting / Re: Driver problem on: March 04, 2012, 04:52:08 pm
I reloaded the drivers with ones I got from off the Internet and things are now working. I am not going to connect the Mega2560 again until I have to other project finished!
Jim
131  Using Arduino / Networking, Protocols, and Devices / Confusing response with APC220 on: March 04, 2012, 04:47:42 pm
I have an Arduino with a temperature module and an APC220 rf module attached. I have another APC220 connected to my PC through a USB/serial converter on Com 7. If I point the serial monitor to Com 7, I see the temperature displayed continuously. I have tried three terminal emulators (Putty, Indigo, and Realterm), pointed them to Com 7 and see no data. I know they are looking at Com 7 because if I point the Arduino IDE terminal to 7 then try to use the others I get the message "Com 7 in use". What I am trying to do is monitor the  signal to make sure it is still working, while programming another Arduino with an APC220 and a LCD, which I have so far not been able to  display the data on. What is different about the IDE's terminal? I am using 9600 baud, no parity everywhere.
Jim
132  Using Arduino / Installation & Troubleshooting / Driver problem on: March 03, 2012, 05:01:36 pm
I just got a Mega 2560 for a project. I plugged it in and windows could not find driver. I searched this site and found that the driver was in arduino-022/ drivers. I loaded this driver and it worked. When I went back to an older project on a Duemilanove. It was no longer found  by the windows xp computer. I am not sure why this was lost but I cannot figure out where this driver went and can not find another. How do I make both work at the same time?

Jim
133  Development / Suggestions for the Arduino Project / Re: USB-Serial adapter gets "lost" on: February 28, 2012, 11:57:49 am
The exact same thing happens in Windows, the only way out is to reboot.

Jim
134  Development / Other Software Development / Re: Trouble writing a library on: February 19, 2012, 05:48:18 pm
Quote
If you use Arduino 1.0 you should use something like:

#if ARDUINO < 100
#include <WProgram.h>
#else
#include <Arduino.h>
#endif

I recall that using libraries in a library on the Arduino platform have some issues. Think you have to include
#include <SHT1x.h>
#include <math.h>
in your main sketch too.

Hope this helpes.


I am using 022 until I hear all the libraries are sorted out.
Putting includes in main sketch no help!
jim
135  Development / Other Software Development / Re: Trouble writing a library on: February 19, 2012, 04:51:42 pm

you can post the code of your libs and sample code.

A better place to put your libraries is in your code folder/libraries, see FILE-> preferences for the location.

Are you shure you killed all instances of the IDE?




I rebooted the computer!

h file

#######################
# This is keywords for THMOD library
#######################
#infdef THMOD_H
#define THMOD_H
#include <WProgram.h>

class THMOD
public:
{
   THMOD();
   ~THMOD();
   float readC();
   float readF();
   float readH();
}
#endif

keyword file

#######################
# Datatypes (KEYWORD 1)
#######################

#######################
# Methods (KEYWORD2)
#######################
THMOD KEYWORD1
readC KEYWORD2
readF KEYWORD2
readH KEYWORD2

cpp file

/* this is an attempt to learn how to write libraries
by putting a wrapper around the SHT1x library
with shorter names*/
#include <SHT1x.h>
#include <math.h>
#include "THMOD.h" // include declaration

#define dataPin  4   // DATA
#define clockPin 5   // SCK
 float temp_c;
 float temp_f;  float humidity;

 //constructor
THMOD::THMOD()
{
   SHT1x sht1x(dataPin, clockPin);
}
//destructor
THMOD::~THMOD() // nothing needed

float THMOD::readC()
{
    temp_c = sht1x.readTemperatureC();
    return temp_c;
}

float THMOD::readF()
{
    temp_f = sht1x.readTemperatureF();
    return temp_f;
}

float THMOD::readH()
{
    humidity = sht1x.readHumidity();
    return humidity;
}

All this does is give me easier names because my right arm is amputated and typing with just your left hand is not easy.
Jim
 
Pages: 1 ... 7 8 [9] 10 11 ... 14