Show Posts
Pages: 1 ... 2119 2120 [2121] 2122 2123 ... 3356
31801  Using Arduino / Interfacing w/ Software on the Computer / Re: controlling an image sequence in processing with adruino on: January 29, 2012, 10:46:28 am
You currently have something like this:
void draw() {
  // increment image index by one each cycle
  // use modulo " % "to return to 0 once the end of the array is reached
  imageIndex = (imageIndex + 1) % images.length;
That should be:
void draw()
where imageIndex is set in the serialEvent() callback, based on the integer extracted from the String object.
31802  Using Arduino / Networking, Protocols, and Devices / Re: Getting mcp4822 and mcp4621 libraries to work in Arduino 1.0 on: January 29, 2012, 10:41:11 am
In Arduino 1.0, it seems like the CS pin is not pulled low and so there is no communication with the chip
Have you tried adding code to explicitly set the CS pin? A lot of libraries now do this automatically.

MCP4822::MCP4822(int csPin, int ldacPin) {
    // Configure chip select and latch pins
    cs = csPin;
    ldac = ldacPin;
    // Set to default configuration
The calls to pinMode() and digitalWrite() have no place in the constructor. The constructor will be called before init() does it's thing, so when init() runs, stuff done in the constructor will be undone.

The library really needs a begin method where the pinMode() and digitalWrite() calls are made (and probable the setGain2S_AB() call, too.

The begin() method, when you add it, should be called in setup().
31803  Using Arduino / Programming Questions / Re: Including reference to library from within a library on: January 29, 2012, 10:33:00 am
Note:  If I remove <clsTimer.h> from the sketch it fails to verify without warnings, which I don't understand, as I would have thought that including the file in clsApp.h would be enough.
You have to understand how the IDE works. It copies your sketch to a temporary folder. It copies any files referenced by your sketch (those that are #included) to the same folder, and copies the corresponding .cpp files.

So, if you have clsApp.h in the sketch, but not clsTimer.h, the sketch and clsApp.h and clsApp.cpp will be copied to the temp. folder. Only the files in the temp. folder are compiled. Since clsTimer.h was not referenced by the sketch, it was not copied, and is not available for clsApp.h or clsApp.cpp to include.

When clsTimer.h IS included in the sketch, it is copied, and clsApp.h/clsApp.cpp can reference it.

The IDE does not recursively scan files to know what really needs to be copied/compiled.
31804  Using Arduino / Interfacing w/ Software on the Computer / Re: controlling an image sequence in processing with adruino on: January 29, 2012, 10:25:02 am
There is an icon, just above the smiley faces, with # on it. That icon should be clicked before posting code. "Why?", you ask. Does your code really look like this:
images = loadImage( "picture" + i + ".png" );

I hope not.

val = analogRead(A5);
val = map(val, 30, 600, 0, 510);
You read an actual value, map that to the range 0 to 510, then read another value and send that one. So, what is the map() doing for you?

In your Processing sketch, you need to do several things.
Import the serial library:
import processing.serial.*;

Define an instance of the serial library:
Serial myPort;

Initialize the instance and tell the serial object to buffer data until something interesting happens (in setup()):
 myPort = new Serial(this, Serial.list()[2], 2400);
  // tell the serial port not to generate a serialEvent
  //until a linefeed is received:

You can print the list of COM ports that Processing knows about:
so that you can use the correct index - 2 in  my case, but it may not be in your case.

add a serialEvent() method.
void serialEvent(Serial myPort)
  // Read the serial data
  String myString = myPort.readStringUntil('\n');

The Arduino code uses Serial.println(), so the value is followed by the carriage return. Processing will buffer data until the carriage return arrives. When it does, it will fire the serialEvent callback.

In that callback, you read the value as a String. Then, you need to convert the value in the String object to an integer, and store the integer in a global variable.

In the draw() function, quit iterating through the images. Instead, draw just the one image whose index is stored in the global variable. To reduce flicker, keep another (global) variable that contains the last image index, and do not redraw if the previous and current index is the same.
31805  Using Arduino / Programming Questions / Re: Including reference to library from within a library on: January 29, 2012, 10:05:48 am
#include <clsTimer.h> and #include "clsTimer.h" look for the file in different places. Try changing <> to "".
31806  Using Arduino / Project Guidance / Re: PRFID trying to make a logging system with 100+ items on: January 29, 2012, 09:38:13 am
Do you know of any good references for things not on the Arduino reference?
31807  Using Arduino / Project Guidance / Re: Router on arduino on: January 29, 2012, 09:36:15 am
In this case one of them goes on the PC how?
It doesn't. They go on Arduinos.

One of these and one of these could be connected to the PC and one of these and one of these on the Arduino to achieve wireless communication between the Arduino and the PC.
31808  Using Arduino / Project Guidance / Re: traffic light with mode button on: January 29, 2012, 09:30:05 am
  Notice how in John's code the { and } line up. Notice how everything in between is properly indented. Notice how much/little white space is used. Notice how much more readable his code is than yours.

  The Tools + Auto format menu item is there for a reason. You should use it regularly.
31809  Using Arduino / Interfacing w/ Software on the Computer / Re: controlling an image sequence in processing with adruino on: January 29, 2012, 09:26:21 am
How can I connect the values from the distant sensor to the 510 pictures I have in processing,so that I can fill my glass of beer by going up with my hand.
Depends on the Arduino code you have for reading the sensor, and the Processing code that you have for reading serial data.

There are examples provided with both Processing and Arduino that show how to send/receive serial data.

Making Processing use that serial data to determine which picture to show is up to you. How that relates to filling your beer glass is a mystery.
31810  Using Arduino / Programming Questions / Re: Copy bits from int to byte on: January 29, 2012, 09:22:50 am
I need to copy the lower 8 bits from an int to a byte.
This is a quite common task. So common, in fact, that the Arduino provides highByte() and lowByte() for just this purpose.

Good that you spent a few seconds looking at the reference material.
31811  Using Arduino / Networking, Protocols, and Devices / Re: Ethernet Shield two way communication? on: January 29, 2012, 09:16:12 am
I have the Ethernet shield working on modified the modified Twitter code
All the words make sense. The order and selection of words do not.

The arduino twitter account is monitored by my regular one and sends text messages for that one only.
"my regular one" refers to what? "for that one only" means?

Would it be possible to somehow reply via SMS with a single character and have the shield turn on an led?
Depends on what you do with your phone, what you send the SMS to, and what that server does with the text message.

Some code would be useful.
31812  Using Arduino / Programming Questions / Re: How to read numbers from serial input and print in big fonts (2 lines) on: January 29, 2012, 08:42:33 am
Unplug the potentiometer, toss it in a drawer.

If the customN() functions draw values correctly, you should be able to, in setup(), do this:
x = 0;
x = 4;
x = 8;
x = 12;
and see the current year. Remove everything in loop.

Does that show the year correctly?
31813  Using Arduino / Programming Questions / Re: I need help with Servo Code on: January 29, 2012, 08:36:43 am
but the servo doesn't move and the Serial Monitor results are either 0 or 180 for pos var.
You only print the value of pos after the for loop. At that point, it will be either 0 or 180.

As to why the servo does not move, you haven't assured us that it is wired correctly and that it is getting sufficient current. Have you tried the sweep example to verify that the servo works?
31814  Using Arduino / Programming Questions / Re: Controlling 2 servos with an acceleromoter on: January 29, 2012, 08:30:03 am
Lovely indenting style and positioning of curly braces. Not.
31815  Using Arduino / Project Guidance / Re: PRFID trying to make a logging system with 100+ items on: January 28, 2012, 10:07:55 pm
What is "anInst"?
An instance of the structure.

Also, to accses data, can I just simply do
Pages: 1 ... 2119 2120 [2121] 2122 2123 ... 3356