Show Posts
Pages: 1 2 3 [4]
46  Using Arduino / Programming Questions / Re: None of the Analog Read Examples are working with 2560 on: October 05, 2012, 08:15:31 am

Yes i connected a wire from A0 to GND directly too, and tried the ReadAnalogVoltage program, but it shows only 5v. And i havent tried the 54 digital pins , only the pwn outputs, but i think the problem is with the ATMega2560 ;/. And it doesn't have any shield on it, and i am using it on wood table.

What about the other analog pins?  Did you try A1-A5? 

47  Using Arduino / Microcontrollers / Re: Need some direction with using ATTINY85 on: October 04, 2012, 10:23:40 pm
Try http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&p=547834
48  Using Arduino / Programming Questions / Re: interfacing arduino to RFID, help on: October 04, 2012, 10:15:42 pm
There are a number of RFID readers out there.  I used an RFID ID-12 (SEN-08419) chip with the breakout board(SEN-08423) from Sparkfun.  

You basically hook it up to the serial pin.  When a card is swiped it sends the card ID over the serial line.  

Here is a small test program to give you an idea of how easy it is.  I X'ed  out the card id's (also from sparkfun).

Code:
char val = 0; // value read for serial port

char peopleCardID[][20] = {
  "XXXXXXXXXXX","XXXXXXXXXXX","XXXXXXXXXXX","XXXXXXXXXXXX","XXXXXXXXXXXX"};
char people[][20] = {
  "Ted", "Frank","Johnny","Franny","Bobby"};

void setup() {
  Serial.begin(9600);

}
void loop () {
  int i;
  char card[20] = "";
  if(Serial.available() > 0) {
    boolean bFound = false;
    i=0;
    while(Serial.available() > 0){
      val = Serial.read(); // read from the serial port
      if ((val >= 'A' && val <='Z') || (val >='0' && val <='9')){
        card[i++] = val;
        delay(10);
      }
    }
    card[i] = 0;
    for (i=0;i<5;i++){
      if (!strcmp(peopleCardID[i],card)){
        bFound = true;
        Serial.print("Hello there ");
        Serial.print(people[i]);
        Serial.println("!!  ");
      }
    }
    if (!bFound){
      Serial.println("Unknown Key!!!");
    }
  }
}

Also here is a link to a project someone did with it with more details. It has wiring diagrams and code as well.  http://www.markfickett.com/stuff/artPage.php?id=373#id12  

Adafruit also has an RFID shield that you can look at.    No wiring needed and she has a library and sample code to use.  Here is the link to the basic sample code https://github.com/adafruit/Adafruit_NFCShield_I2C/blob/master/examples/readMifare/readMifare.pde
49  Using Arduino / Programming Questions / Re: Is it possible to use the digital OUTs as INs? on: October 04, 2012, 09:53:52 pm
As jonathanped said, they can be used for either input or output.  You have to call the pinMode function

So to make digital pin 10 an input
pinMode(10, INPUT);

To set it for output
pinMode(10, OUTPUT);

One thing to add though is that it doesn't have to happen in the setup function but almost always that is where you want to set it.   It can be set anywhere at anytime and you can even change the mode in the same program.  This is rare however and the only time I can think when one does this is with the PING sensor which requires you to send and receive a signal on the same pin.

Hope that doesn't add to the confusion.  smiley
50  Topics / Robotics / Re: Servo and Ultrasonic sensor on: October 04, 2012, 09:01:42 pm
If you are using the HC-SR04 the 1000 microsecond delay is a bit long.  

The specification doc says it should 10 microseconds (delayMicroseconds(10)).
Here is the doc:
http://jaktek.com/wp-content/uploads/2011/12/HC-SR04.pdf

Also you should specifically hold the trigger line LOW first for a little bit of time before setting it HIGH (just like the PING sensor).

Try the following code:
Code:
void loop() {
  int duration, distance,pos=0;
  digitalWrite(trigPin, LOW); 
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  duration = pulseIn(echoPin, HIGH);
  distance = (duration/2) / 29.1;
  .....
51  Using Arduino / Programming Questions / Re: Serial dumping _VMDPR (Really unknown error please help!) on: October 04, 2012, 08:20:15 pm
How did you wire it up?   The PI runs at 3.3v and the Arduino runs at 5v so I assume you ran it through a converter.  There is one example on the web where someone ran it though a CD4050.   See the page here http://www.andremiller.net/content/raspberry-pi-and-arduino-via-gpio-uart

Assuming you did not directly connect them I am unsure what these values are supposed to mean.  They aren't ASCII values because they are larger than 8 bit chars (values > 255). 


52  Using Arduino / Programming Questions / Re: None of the Analog Read Examples are working with 2560 on: October 04, 2012, 10:23:20 am
I already did it, but it only shows 1023...

So you are saying that even running a wire from A0 to ground you are getting 1023?  Are you connecting a wire from A0 to the GND port on the Mega directly?

If so something is wrong.  Even if there is a short running it directly to ground should bring it down.   
Is your Mega sitting on top of a metal table or something?  There are no shields installed right?



53  Using Arduino / Programming Questions / Re: None of the Analog Read Examples are working with 2560 on: October 03, 2012, 05:31:18 pm
It sounds like your pot is hooked up wrong or something electrical is wrong with the Mega since you said the Uno works.

Did you try running the A0 pin straight to ground?  Just to see if the Mega will report back 0?  If that works take the wire out of A0 completely and see what the results are.  'Normally' you get fluctuating values.  If it comes back as 1023 there is a problem.   
54  Development / Suggestions for the Arduino Project / Bug: Ethernet Library Sample Code WebClientRepeating on: October 03, 2012, 05:20:10 pm
I originally posted this in http://arduino.cc/forum/index.php/topic,125510.0.html but since it appears to be a bug I will repost it here as well.

In the WebClientRepeating sample code for the Ethernet library there is a line for determining the posting interval.   The line is

Code:
const unsigned long postingInterval = 60*1000;  // delay between updates, in milliseconds

The problem is the actual value of the postingInterval is wrong when I print it out (it is 4294961760). It seems to be a casting/overflow problem with the compiler/preprocessor. It looks like it is treating the 60 and 1000 as signed integers.

I broke this out into very short sample code to demonstrate:
Code:
const unsigned long postingInterval = 60*1000;
const unsigned long postingIntervalB = (long)60*1000;

void setup() {
  Serial.begin(9600);
  Serial.println(postingInterval);
  Serial.println(postingIntervalB); 
}

void loop() {}

When I run this I get back the following values:
Code:
4294961760
60000


Other Ethernet samples use 10 seconds (10*1000) and do not appear to have this problem.  I assume it is because it is withing the range of an signed integer and that is how the compiler/preprocessor is treating the values. 
55  Using Arduino / Programming Questions / Re: Ethernet WebclientRepeating sample - postingInterval on: October 03, 2012, 05:07:13 pm
it appears that one other person had the same problem on the forum  http://arduino.cc/forum/index.php/topic,116279.0.html

They never got the code to work and it appears he had the same problem I had.   It never actually sent data because the postingInterval is much larger than 60000.   

Um... I suppose I should report this... somewhere.   smiley-roll-blue
56  Using Arduino / Programming Questions / Ethernet WebclientRepeating sample - postingInterval on: October 03, 2012, 02:02:10 pm
In the WebClientRepeating sample code for the Ethernet library there is a line for determining the posting interval.   The line is

Code:
const unsigned long postingInterval = 60*1000;  // delay between updates, in milliseconds

The problem is the actual value of the postingInterval is wrong when I print it out. It seems to be a casting/overflow problem with the compiler/preprocessor.
I broke this out into very short sample code to demonstrate:

Code:
const unsigned long postingInterval = 60*1000;
const unsigned long postingIntervalB = (long)60*1000;

void setup() {
  Serial.begin(9600);
  Serial.println(postingInterval);
  Serial.println(postingIntervalB); 
}

void loop() {}

When I run this I get back the following values:
Code:
4294961760
60000


The first value is obviously incorrect while the second one is fine.   What bothers me is this was happening in the Ethernet library sample code and the httprequest function was never called because of such a high postingInterval value.

Has this been posted before and I just didn't see it in the forum (I got back a ton of unrelated results when searching). Or is something weird going on with my three Arduino installs?
57  Using Arduino / Networking, Protocols, and Devices / Re: onRequest handler and Serial.print on: April 24, 2012, 06:35:57 pm
It's funny (actually it isn't) but I know very well NOT to put Serial.print calls in an ISR and yet... I did it anyway because my head was not quite with it.   smiley-red

Thanks.

58  Using Arduino / Networking, Protocols, and Devices / Re: I2C - onRequest not working on: April 24, 2012, 04:27:27 pm
I found issues when using Serial.print(ln) statements in request handlers.   Once I took them out it worked better.
59  Using Arduino / Networking, Protocols, and Devices / onRequest handler and Serial.print on: April 24, 2012, 04:25:48 pm
I was successful in getting an NXT (using Robotc) and an Arduino to talk to each other over I2C but there was a problem I hit that I did not expect. 

I found that if I included Serial.print statements in my onRequest handler the data being sent to the NXT master would be "mangled".   I have confirmed this with a Saleae logic analyzer and can easily reproduce this problem.

It appears others 'might' have had this issue.  When I searched the forum there were some unanswered posts from people who were having similar problems (for example http://arduino.cc/forum/index.php/topic,90516.0.html ).

Is it possible to update the Wire.onRequest library documentation page to warn people about this issue?  (Or is this common knowledge and I just didn't know about it?    smiley-mr-green )

Thanks.
60  Using Arduino / Programming Questions / Re: Nav LED loop on: January 21, 2012, 04:08:18 pm
I have some 'general' suggestions.    For readability create constants to represent your lights like so:


Code:
const int LightNavRG = 13;
const int LightNavstrobe = 12;
const int LightTopBeacon = 8;
const int LightBottomBeacon = 7;

int incomingByte;

void setup() {               
  pinMode(LightNavRG        , OUTPUT);  // Nav Red and Green
  pinMode(LightNavstrobe    , OUTPUT);  // Nav Strobe
  pinMode(LightTopBeacon    , OUTPUT);   // Top Beacon
  pinMode(LightBottomBeacon , OUTPUT);   // Bottom Beacon
  Serial.begin(9600);
}
....

I would also put your blinking code into various functions.

For now the code is fine but technobabologist is correct that the delay function does stop everything.   

Also in the two cases where you want to turn your lights all on or all off... there is an advanced feature that allows you write to the port registers directly which makes that particular part of the code much faster.  I would only use it if you really needed to tighten up your code.   You can find information about it here:  http://www.arduino.cc/en/Reference/PortManipulation
Pages: 1 2 3 [4]