Show Posts
Pages: [1] 2
1  Using Arduino / Programming Questions / Re: Hardware Serial Port Referencing on: March 17, 2013, 09:30:42 pm
Thank you ever so much!  This works perfectly!

I am not quite sure what is happening, but it works and for now that's all that matters.

Again, thank you for your help!

and thank you for pointing out the code blocks pointer, I was wondering how you guys did that smiley
2  Using Arduino / Programming Questions / Re: Hardware Serial Port Referencing on: March 17, 2013, 08:31:14 pm
I thank you guys for being patient with me, however, I am still a little stumped.

I need my class to contain all 4 hardware serial ports as references so that I can work with them locally inside the class.

Your example for a single reference worked fine for a singe serial port reference.

How do I get the constructor to deal with all of the references I pass to it?


// Header file

class MyClass {
      HardwareSerial&   portA, portB, portC, portD;

       MyClass(HardwareSerial& sRefA, HardwareSerial& sRefB, HardwareSerial& sRefC, HardwareSerial& sRefD) {
                // How to assign the references passed to the constructor to the local class objects?

// Or deal with them in the source file constuctor...

// Source file
#include <MyClass.h>

MyClass::MyClass(HardwareSerial& sRefA, HardwareSerial& sRefB, HardwareSerial& sRefC, HardwareSerial& sRefD) {
      portA = sRefA;       // Does not work
      portB = sRefB;
      portC = sRefC;
      portD = sRefD;


3  Using Arduino / Programming Questions / Re: Hardware Serial Port Referencing on: March 17, 2013, 05:55:57 am
Ok, that last suggestion works wonderful for a single reference, but...

What if I wanted to have the constructor deal with multiple hardware serial port references?

And could I get them into an array?

class MyClass {
        HardwareSerial&   portA;
        HardwareSerial&   portB;
        HardwareSerial&   portC;
        HardwareSerial&   portD;

        // What about
        HardwareSerial&   ports[4];

        MyClass(HardwareSerial& sRefA, HardwareSerial& sRefB, HardwareSerial& sRefB, HardwareSerial& sRefC, HardwareSerial sRefD)


That's as far as I have gotten, need further direction....

4  Using Arduino / Programming Questions / Hardware Serial Port Referencing on: December 24, 2012, 07:58:17 pm
Hey All smiley

I am trying to figure out how to use references with the hardware serial ports.

// File: sketch.ino

#include <Arduino.h>
#include <TestSerial.h>

TestSerial testSerial(Serial);

void setup() {

void loop() {
  if (Serial.available() > 0) {
    byte iByte =;

// File: TestSerial.h
#ifndef TestSerial_h
#define TestSerial_h

class TestSerial {
     // Here is where I want to declare whatever it is I need to declare to get the reference supplied by the constructor
     // but I have no idea what to do.  I have tried:
     HardwareSerial& privateSerial;  
     // Which generates a compiler error cannot convert 'HardwareSerial' to 'HardwareSerial*' in assignment

    TestSerial(HardwareSerial& localSerial);
    void sayit();


// File: TestSerial.cpp

#include <Arduino.h>
#include <TestSerial.h>

TestSerial::TestSerial(HardwareSerial& localSerial) {
  // Here is where I want to put the reference 'localSerial' into the 'privateSerial'
  // I tried:
  privateSerial = localSerial; - No go because of compiler error

void TestSerial::sayit() {
  privateSerial.println("HELLO WORLD!");

Any ideas?
5  Using Arduino / Networking, Protocols, and Devices / Re: Change Ethernet SPI Slave Select PIN. on: December 13, 2012, 12:26:08 pm
I found where to change the sd card pin in 'Sd2PinMap.h'
uint8_t const SS_PIN = 53;

I can't seem to find where to change it in the ethernet library
6  Using Arduino / Networking, Protocols, and Devices / Change Ethernet SPI Slave Select PIN. on: December 13, 2012, 12:03:37 pm
I would like to know where I can change the slave select pin values for the ethernet shield and sd card in the libraries.

I would like to alternate pins than the defaults.

I know about keeping the NSS pin as output, 10/53..

Thanks smiley

7  Using Arduino / Programming Questions / Re: pH sensor code on: December 10, 2012, 11:30:08 pm
Arduino TX Pin to pH Stamp RX pin
Arduino RX Pint to pH Stamp TX pin
8  Using Arduino / Programming Questions / Re: pH sensor code on: December 09, 2012, 10:19:33 pm
Please post example code:

The Atlas pH stamp will take a minimum 262 millis from receipt of command untill it will respond with the pH reading.  If the debug led's are enabled the lag will double. By default the pH Stamp module uses the following serial settings: 38400, 8, N, 1.


// Send Single Read Command To Stamp

// Give stamp time to do it's thing

// Read the stamp data

float myPH = Serial3.parseFloat();

Hope this helps, if you need more info, just post question

9  Using Arduino / Programming Questions / Parsing Float Values on: December 08, 2012, 12:13:05 pm
I would like to know how I can parse the float value from a byte array or a method to parse a float value from the sd card.

I have a config file I want to use that contains a single float value on each line. The sd examples show reading the line contents into a byte array. How can I parse the float value from a byte array. Sample Data: 123.45

I searched the net and found some obscure examples none of which I could figure out or get working.  Any help would be appreciated.

10  Using Arduino / Sensors / Re: RTC DS1307 on: November 21, 2012, 07:23:15 pm
Note: I am giving up on these modules.  I have two of them and one of them keeps data on reset and not on no power and the other one doesn't keep data either way.  I don't have electrical knowledge to debug hardware so I say caution to those considering this product.
11  Using Arduino / Sensors / RTC DS1307 on: November 21, 2012, 05:58:07 pm
I have two DS1307 I2C RTC Modules


I hooked up the rtc to the mega and loaded the TimeRTCSet example from the Time examples

the sketch reports the time as 0:00:00  1 1 2000. I sent the command T1353540094 which is a valid unix time and the sketch starts reporting
23:20:00  21-11-2012 ... Ok seems fine.  I hit the reset button on the arduino and the sketch resets and the time is still valid.  I unplug the mega from the usb, plug it back in and start the serial monitor and the date defaults back to 0:00:00 1 1 2000.  I checked the battery and it has 3.93v, I checked to see if the rtc was actually talking on the i2c bus by adding a Serial.println(RTC.get()); to the main loop and I get incremented time as I would expect.  I disconnected the rtc from the arduion and the sketch stops so I can assume communications are working properly.  I do have 10k pull resistors installed on sda and scl as tutorials have shown.

I asked the guys in irc and one of them said that if I didnt see voltage on the VCC / GND pins then the battery wasnt working, and I thought that there would be some kind of mechanism to prevent voltage/current flow from the battery to the vcc pin, dont know what to think...

Any help would be appreciated


Any ideas?
12  Using Arduino / Programming Questions / Re: Flash & Methods on: November 15, 2012, 08:06:48 pm
Thank you for the nudge in the right direction
13  Using Arduino / Programming Questions / Re: need help with code on: November 15, 2012, 01:16:34 pm
I attached 3 files that I found that work for the 4-wire ultrasonic sensors, at least the one I have.

Create a directory in your arduino.x.x.x/libraries folder named Ping4 and copy the attached files there

in sketch:

#include <Ping4.h>

int TriggerPin = 12;
int EchoPin = 11;

Ping4 Sensor;

void setup() {
  pinMode(TriggerPin, OUTPUT);
  pinMode(EchoPin, INPUT);

void loop() {

Moderator edit: The usual. Grrrr
14  Using Arduino / Programming Questions / Flash & Methods on: November 15, 2012, 12:00:20 pm
Heys guys;

Here is my code:

#include <Flash.h>
#include <UTFT.h>

UTFT tft(ITDB32S, 38, 39, 40, 41);

FLASH_TABLE(int, fTable, 4, {0,0,10,100}, {0, 40, 40, 150});

void setup() {
void loop() {


void DrawMyRect() {
  tft.drawRect(fTable[0][0], fTable[0][1], fTable[0][2], fTable[0][3]);  // DOES NOT DISPLAY
  tft.drawRect(0, 0, 10, 100);  // WORKS

If I try a Serial.println(fTable[0][0], fTable[0][1], fTable[0][2], fTable[0][3]);
The serial monitor display's the correct information, any ideas would be appreciated

15  Using Arduino / Programming Questions / Re: Flash.h on: November 15, 2012, 12:40:38 am
Thanks, that works,
Pages: [1] 2