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 
|
|
|
|
|
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?
IE:
// Header file
class MyClass { private: HardwareSerial& portA, portB, portC, portD;
public: 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 { private: HardwareSerial& portA; HardwareSerial& portB; HardwareSerial& portC; HardwareSerial& portD;
// What about HardwareSerial& ports[4];
public: 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  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() { Serial.begin(9600); } void loop() { if (Serial.available() > 0) { byte iByte = Serial.read(); testSerial.sayit(); } } // File: TestSerial.h #ifndef TestSerial_h #define TestSerial_h class TestSerial { private: // 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 public: TestSerial(HardwareSerial& localSerial); void sayit(); }; #endif // 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?
|
|
|
|
|
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.
Serial3.begin(38400);
// Send Single Read Command To Stamp Serial3.print('R'); Serial3.print(13);
// Give stamp time to do it's thing delay(300);
// 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.
Thanks:
|
|
|
|
|
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 Link: http://www.ebay.com/itm/190720534421?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649I 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 Thanks Any ideas?
|
|
|
|
|
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); Serial.begin(9600); }
void loop() { Sensor.Read(); Serial.println(Sensor.Distance()); delay(1000); } 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() { DrawMyRect(); } 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
|
|
|
|
|