Show Posts
Pages: 1 ... 2262 2263 [2264] 2265 2266 ... 3234
33946  Using Arduino / Programming Questions / Re: input variables - communicate with arduino through PC on: October 07, 2011, 04:39:28 pm
Dont hold back on criticism either. I wont get mad and its the only way i will learn - by critique from more advanced users.
There is a difference between critique (I think that this code could be improved by...) and criticism (you idiot, can't you do anything right).

I'll keep with the critiquing and try to cut down on the criticizing.
33947  Using Arduino / Networking, Protocols, and Devices / Re: Can't read data from GPS module on: October 07, 2011, 04:36:18 pm
A MAX232 chip will solve all of your problems. Just whacking off the -5V signal isn't enough.
33948  Using Arduino / Networking, Protocols, and Devices / Re: Serial Communication between a cell phone and Arduino Mega 2560 on: October 07, 2011, 03:28:38 pm
Crossposting all over the place won't help.

The key is right there in your post title. Use the Serial.print() command to send the AT commands to the phone, and the Serial.available() and commands to get the response (or any phone initiated communication).

Once you have data coming from the phone, it is up to you to parse and act on that data.
33949  Using Arduino / Networking, Protocols, and Devices / Re: Bluetooth RN-42 command mode problem on: October 07, 2011, 03:24:47 pm
However, to start with, since this line is commented, it doesn't explain why I get all kind of strange characters back to the Arduino serial monitor aftert having typed $$$. Or do you have a clue?
After that function ends, having done nothing but set the baud rate to 115200, loop() is called, to read any data coming from the bluetooth device. The data is then send to the serial port.

If what is displayed in the Serial Monitor isn't intelligible, either the Serial Monitor and Serial instance are not exchanging data properly (mismatched baud rate) or the Arduino and bluetooth device are not (again, mismatched baud rate seems most likely).
33950  Using Arduino / Networking, Protocols, and Devices / Re: Serial Communcation Problems on: October 07, 2011, 03:06:28 pm
When I look at serial1 using multiple 3rd party serial port monitors the data doesn't match that in Str1 and there is no decipherable pattern.
An understanding of the difference between Serial.print() and Serial.write() would be useful.

The Serial.print() function converts the data to be sent to a string, and sends that string. The HEX as the second argument tells the Serial.print() function to convert the value using base 16 numbering, so the resulting string will contain HEX characters.

What you apparently want to do is to send the bytes in the array as bytes, not strings, which is what the Serial.write() function does.
33951  Using Arduino / Programming Questions / Re: using PIR Sensor to fading LED on: October 07, 2011, 02:56:56 pm
  int val = digitalRead(inputPin);      // read input value
  if (val == HIGH)                      // check if the input is HIGH
    analogWrite(firstLED, 255);      //turn LED on if motion dected
  analogWrite(firstLED, 0);
If the sensor is HIGH, turn the LED on. Then, regardless of whether the pin was HIGH or LOW, turn the LED off. Not exactly what I would be doing, but, OK.

  if(val == LOW){
A comment that describes whether you think this means motion or no motion would be useful. Presuming that it means that there is no motion, you do some stuff.

    if(firstLED, 255){
My idea with the second if statement is to simply detect when the sensor throws a LOW  and when the LED is on and then start the fade sequence.
The idea with the second if statement may be to detect that firstLED contains 255, but that is NOT the purpose of the comma operator. That is the purpose of the == operator.

Just because the compiler didn't complain about the code does not mean that it is going to do what you think it will. It KNOWS what the comma operator does. Apparently you don't. I couldn't explain what it does, either, so don't feel too bad. I do know that it is not the correct operator to use here.
33952  Using Arduino / Programming Questions / Re: Detect data value changes on: October 07, 2011, 02:45:24 pm
Literals are treated as integers in the absence of directives to the contrary, so:
unsigned long timeDelay=600000;
would still use an int register to hold the value (which is too small) before it was assigned to the variable timeDelay.
unsigned long timeDelay=600000UL;
uses an unsigned long register to hold the value before it is assigned to the unsigned long variable.

Using a variable in the if test IS better.

If I change the 600000 to 600000UL it doesn't work at all.
What does happen? "Nothing. The if block is never entered" is a perfectly valid answer.

Still, we need to see the rest of your code to see how the other variables in the if statement are valued.

33953  Using Arduino / Programming Questions / Re: How to control servo motor via user serial monitor analog input? on: October 07, 2011, 02:38:43 pm
How do I make it so that when the "System deactived" pops up on the serial monitor after hitting my push button, it deletes the "System active Enter degree(s) 0-180." line and just displays "System deactived".
To do this, you need to use something other than the Serial Monitor that comes with the Arduino. What you use needs to understand something like VT100, and you need to include appropriate VT100 codes in what you send to make it clear the screen.

In a former job, I knew all about how to make VT100 screens do all kinds of cool stuff, but that was 25 years ago.
33954  Using Arduino / Programming Questions / Re: input variables - communicate with arduino through PC on: October 07, 2011, 02:34:00 pm
then the arduino would comm with the PC and ask the user for the three variables they wish to input.
You may just be having a hard time explaining to us what is very clear in your mind, but it is best to think of the Arduino as an idiot that needs to be told exactly what to do.

The Arduino should not be asking the PC what to do. The PC should tell the Arduino what to do.

So, you need to develop an application for the PC (as I mentioned earlier, I like C# for this, and it is free from Microsoft, now) that interacts with the user, and sends directives to the Arduino.

The application could have fields where the user keys in data, or some more idiot-proof method. For instance, if you want to collect on time, you could present a text field, where the user could type 3 (for three seconds) or three or -4 or forever or banana.

Now some of the input makes sense, and some does not. Alternatively, you could use a slider that had a lower limit of 0 and an upper limit of whatever seems reasonable. With that, the user can't enter an invalid value. Pretty hard to drag the slider so that the value is banana.

Pulse count could be done the same way. 0 would mean forever. Any other value would mean a discrete number of times.

Once you know what data you want to send to the Arduino, the next step is to figure out how. The choices are ASCII and binary. Binary is easy when the values are byte sized, but more difficult when the values are ints or floats.

If you go with ASCII (and I'd recommend that to start with), you need to use start and end of packet markers, so the Arduino knows when a whole message has been received. For instance, you might send "<12, 10, 100>" to tell the Arduino to generate 12 pulses, with 10 millisecond on time and 100 millisecond off time.

I have made a basic flowchart on how i would like it to work.
Excellent first step. Sharing it would be step 2.

Basically I just need a few tips on how I might get started. Im not looking for someone to write the code for me. I want to be able to learn from it; I know it will be challenging. But I feel if i only write basic code - I feel I will learn nothing from this awesome microcontroller.
Getting two computers to talk to each other, to share data, and to act appropriately with that shared data is never a trivial task. So, you WILL learn (or re-learn) something.

Your attitude seems right to get this project done.

Break the project into steps, and work the steps one at a time. On the PC:
Create a form to collect the data from the user.
Connect to the serial port.
Format the data to send to the serial port.
Send the data to the serial port.
Read the response, if any.
Show the response to the user.

On the Arduino:
Check for serial data to read.
If any, read and store the serial data, if there is room. As each character is read, see if it is a start marker, and end marker, or something else.
Do different things with the start marker (initialize the array, initialize the index, and set a started flag and clear the ended flag), the end marker (set the ended flag and break out of the while loop), or other character (store it in the next position in an array, increment the index, and append a NULL, if there is room).

When the started and ended flags are true, parse the data.

When you have some data, do the appropriate stuff with that data.

I have a C# application that talks to an Arduino that you could use as a starting point. If you are interested, PM me with an e-mail address, and I'll send it to you.
33955  Using Arduino / Programming Questions / Re: using PIR Sensor to fading LED on: October 07, 2011, 02:08:42 pm
My origional I did that didn't work was a nested if such as:
Quit with the "such as" crap. Post ALL of your code. That last stuff you posted doesn't even make sense.

if(firstLED, 255){
Computers and compilers are stump stupid. They will do exactly what you tell them to do, even when you can't tell them to do what you want, or don't understand the language well enough to tell them something that makes sense.

C has a comma operator, so, syntactically, that statement is valid, but it does not do what you might think it does. If you explain what you think it is supposed to do, we can explain why that is not the case.
33956  Using Arduino / Programming Questions / Re: Hex over uart & checksum calculations on: October 07, 2011, 02:03:42 pm
I know about serial.println(val,hex);, but don't know if this is already "preformatted" or not (i.e., since I have it in 0x format, do I just send as ASCII, or do I send 0x07,hex?).
The second argument to the serial.print() function defines the base to be used when converting the value to a string.

If the device you are talking to says that it expects hex values, it means that it wants binary data, not string data, and, therefore, Serial.print() is the wrong function to use. Serial.write() is the correct function.
33957  Using Arduino / Interfacing w/ Software on the Computer / Re: Mega and Scada? on: October 07, 2011, 01:53:16 pm
I cant find the Arduino and actually make Scada talk to it...
I downloaded the sketch that was linked to in step one.

I downloaded the software that was linked to in step two. I installed it. I ran the movie, stopping if often. I recreated the project described, except that I had to use different pictures for the LED on and LED off images.

I uploaded the sketch to the Mega, and tried running the Scada application. It didn't seem to work. I switched to a Duemilanove, and still nothing but a blank form in the Scada application. I discovered that I had three forms, two of which were blank. When I deleted the two blank forms, the Scada application appeared correctly. I had several icons in the task bar some of which were green and some were red. I closed the Scada application, and killed all the processes related to it.

I started the Scada application back up, and ran it. My form with buttons appeared, and three icons in the task bar lit up, green. I was able to make the light come on and go off on the Duemilanove.

I closed the application, stopped Scada, and unplugged the Duemilanove. I plugged in the Mega again, and got the COM port number it was using. I changed the Scada application to use that number. I ran the Scada application, and got all the icons. Pressing the On button turned on the LED on the Mega. Pressing the Off button turned it off.

So, I think you need to describe what you did.

The movie, in my opinion, was by no means the best way to define how to use the application. Screen shots and explanatory text in html pages would have been far better.

And, I want to add more functions, but I cant find any info or logic "system" to tell the Arduino what I want....
You'll need to define this a little better. Clearly, the link between the Scada application and the specific pin activated on the Arduino leaves a bit to be desired. But, more actions can be defined in the Scada application, using more than register 0, and the Arduino sketch can be extended to handle more than register 0 actions.
33958  Using Arduino / Interfacing w/ Software on the Computer / Re: Processing reading serial affecting servo control? on: October 07, 2011, 12:01:03 pm
Yes I am, is this problem?
Most likely. The source of power when the USB cable is connected is not the same source of power as when the USB cable is not connected.

The current required to move the servo may be marginally safe when the Arduino is powered by batteries/wall-wart, or it may not.

The current required to move the servo simply may not be available when the Arduino is USB powered.

In any case, running all the current that the servo needs through the Arduino is not a good idea.

The servo should be powered independently of the Arduino (with the grounds connected), and simply commanded by the Arduino.

const int tagLength = 13; //  13 = 0-12
I think your math is wrong. 0 minus 12 is -12, not 13. smiley
33959  Using Arduino / Programming Questions / Re: Trouble with Tweet Lib on: October 07, 2011, 11:48:19 am
This topic always amazes me.

I have been working on an environmental monitoring system for my company's server room.
So, why can't you use one of your own servers, with access restrictions that YOU control, instead of Twit?

33960  Using Arduino / Programming Questions / Re: relay activation on: October 07, 2011, 11:45:51 am
fast and dirty do a
delay (1000);
Even better, of course, is to use millis() to record when you turned the relay on, and ignore any requests to turn the relay on again unless the time between the new request and the old (successful) request is greater than the threshold. Look at the blink without delay example.

For why, suppose that the time was 1 hour, instead of 1 second, and the Arduino was displaying the time, too.

Using millis(), the Arduino would continue to display the time. Using delay() it would not.
Pages: 1 ... 2262 2263 [2264] 2265 2266 ... 3234