0

lezzon 5
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

by timv on Sat Dec 15, 2007 5:47 pm

My next move in this situation would be to change "int switchPin = 2;" to "int switchPin = 3;" then move the wire over one hole and see what happens. It'll tell you whether there's a problem specific to that digital i/o port (as it is starting to appear to be) or to something else.

It might also be interesting to try setting up the basic blinkie demo program with the led on digital port 2. You'd be testing output rather than input, but if it's totally hosed--or maybe just not getting signal through the protoshield--you'd at least know that.

Keep at it. 5% inspiration and 95% perspiration, to quote some other famous guy.
timv
 
Posts: 82
Joined: Thu Nov 01, 2007 4:13 pm

by tomp on Sat Dec 15, 2007 6:01 pm

It looks like the switch works. However, you're plugging the white cable directly into pin 2 without using a resistor, which is dangerous; I really wouldn't do that.

Here are some ideas:

1. Use a resistor to connect pin 2 to the breadboad and use one of the colored wires that came in the Starter Kit (rather than that white cable you're using in the photos) to connect that resistor to the switch.

2. If that doesn't help, change your sketch to say 'switchPin =3', upload it to the board. After it's been uploaded, move the resistor to pin 3 and try again.

tomp
 
Posts: 57
Joined: Sun Nov 25, 2007 9:07 pm
Location: South Orange, NJ

by magician13134 on Sat Dec 15, 2007 7:56 pm

First off, I am using a resistor... It's between 5V and the switch. Secondly, that jumper works fine, but I'll try again. Also I have tried pin 3, same thing. I'll try outputting and let you know how it goes. Thanks


*Cry* I just tried everything you guys suggested. Firstly, pin 2 works fine as an output. Secondly, NO pins works as inputs. I tried writing the code piece by piece to see if I could trap the problem. It's definitely the digitalRead. Everything else works fine. Here's my code:
Code: Select all | TOGGLE FULL SIZE
int ledPin = 3;                // LED connected to digital pin 13
int inputPin = 12;               // choose the input pin (for a pushbutton)
int val = 0;

void setup()                    // run once, when the sketch starts
{
  pinMode(ledPin, OUTPUT);     // sets the digital pin as output
  pinMode(inputPin, INPUT);
}


void loop()                     // run over and over again
{
  val = digitalRead(inputPin);
  if (val != 0){
    digitalWrite(ledPin, HIGH);
  }
  else{
    digitalWrite(ledPin, LOW);
   }
}



And here is my result:
http://www.magicsoftinc.com/Arduino.mpg

WHAT IS WRONG WITH MY ARDUINO?!
magician13134
 
Posts: 1119
Joined: Wed Jun 13, 2007 9:17 am
Location: Ann Arbor

by timv on Sat Dec 15, 2007 11:53 pm


Wow! That's way cooler than anything I've gotten my Arduino to do! :-)

How did you have that wired? Is that a resistor on port 3 and then a jumper from it to ground?

It looks like the port is picking up the capacitance of your hand, and reading it like a switch press, like how a Theremin works.

I don't know what to suggest for you here. I'm a lot stronger on software than electronics, and we're getting into stuff beyond my depth.

Pure blue-sky, but have you checked your supply voltage? Have you tested the resistance of your resistor? Yeah, grasping at straws, but it has to be something...

Another thought: Could you set up any of these experiments on the bare Arduino, without the proto shield? It might be pure superstition, but I'd want to know.

Even if it's a bad AVR chip, that's not a show-stopper. They're only a few bucks.

Maybe someone else will have a better idea. A lot of us might learn something from this one.
timv
 
Posts: 82
Joined: Thu Nov 01, 2007 4:13 pm

by magician13134 on Sun Dec 16, 2007 1:16 am

The resistor is from 5V. Then a jumper takes it to Digital 2 (INPUT). I noticed while filming it, that it did the same thing with my camera (turned on when it was close), but ONLY when the camera was on. My resistor is reading steady at 99.0 ohms....
magician13134
 
Posts: 1119
Joined: Wed Jun 13, 2007 9:17 am
Location: Ann Arbor

by timv on Sun Dec 16, 2007 3:12 am

Huh... The jumper goes to d2, and you still have "int ledPin = 3;" in your Arduino sketch? Even stranger...

99 ohms from resistor marked 100 is perfectly ok.

What do you think about trying it without the proto shield? Using a couple of jumpers with alligator clips on each end, I'd think that you'd be able to wire up the lesson 5 switch circuit. (I only have a Boarduino, so I'm guessing.)

I suppose the other obvious thing to try at this point would be swapping in a different Atmel chip, unless someone comes up with a better idea. But if you don't have a spare already, it'll be a few days before that's an option. Might as well keep trying other stuff in the mean time.

I still really dig that proximity effect in your video. After you've figured out what the problem is, I'd love to make a circuit that does that on purpose.
timv
 
Posts: 82
Joined: Thu Nov 01, 2007 4:13 pm

by tomp on Sun Dec 16, 2007 3:34 am

timv wrote:I still really dig that proximity effect in your video. After you've figured out what the problem is, I'd love to make a circuit that does that on purpose.

This is a known effect. See
http://www.arduino.cc/playground/Code/CapacitiveSensor
and
http://www.arduino.cc/playground/Main/CapSense

tomp
 
Posts: 57
Joined: Sun Nov 25, 2007 9:07 pm
Location: South Orange, NJ

by timv on Sun Dec 16, 2007 3:58 am



Awesome! Thanks for the links. I'll definitely try that.

So does it shed any light on magician's situation? (It's getting late and I'm not quite feeling sharp enough to take it all in right now.)
timv
 
Posts: 82
Joined: Thu Nov 01, 2007 4:13 pm

by magician13134 on Sun Dec 16, 2007 10:15 am

Darn, I thought I'd discovered something awesome! :wink:
Anyway, I looked over the circuit again, I had made a couple mistakes last time. The 5V resistor connects to a jumper which goes to my input pin (12). Not, what did I say last time? Pin 2? 3? Anyway. It also turns out that the resistor was not plugged in (to 5V), rather jammed between the breadboard and 5V socket. That's what was causing the proximity sensing effect. Once I plugged it into the socket, the sketch seemed to work. The light was on, I unplugged the jumper and it went out. Then I plugged the jumper in again, and it went back to not working. I tried it without the protoshield and got the same results. I guess now, the only option would be a new chip? Will Adafruit replace it? Should I try and sample it? Or should I do it the old-fashioned way and buy one? Thanks for your help.

(Maybe someone else could try hooking up a circuit with my code and see what happens)
magician13134
 
Posts: 1119
Joined: Wed Jun 13, 2007 9:17 am
Location: Ann Arbor

by timv on Sun Dec 16, 2007 8:47 pm

Thanks for posting the extra info on what you were doing. That capacitive effect is still puzzling to me. The two examples that TomP posted both used a counting loop to time how long a port took to drain down after intentionally charging it up. But your code just checked whether it was high or low. Interesting...

I have a real-world project that needs a lot of attention tonight, but even without trying to your code I can't imagine why it wouldn't work correctly. That's about as straightforward as can be.

I tried to Google a little bit to see if anyone had reported a similar problem with AVR digital inputs not working, but didn't find anything. It's hard coming up with search terms that narrow down the results much for that. I haven't read anything previously about what happens When AVR Chips Go Bad, and no first-hand experience with that either.

Ladyada will likely chime in here tonight or tomorrow, and she's the one to say whether she'll replace the chip or not.

Trying to get free sample chips is always good fun anyway, whether you actually need them or not. :-) A sample wouldn't have the Arduino bootloader on it of course, but there are ways around that.

Sorry if I'm out of ideas for more things to try. You could always post the "clear high-resolution photos of both sides of the boards" and we could all look for soldering issues or something.
timv
 
Posts: 82
Joined: Thu Nov 01, 2007 4:13 pm

by adafruit on Mon Dec 17, 2007 1:00 am

try using the internal pullups, that is: set digitalWrite(inputPin, HIGH);
that should turn on the pin as a pullup. does it still flake out?

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

Please be positive and constructive with your questions and comments.