Show Posts
Pages: [1] 2
1  Topics / Device Hacking / Re: Circuit Bending Nintendo (NES) - Use transistors as switches? on: March 17, 2011, 02:31:11 am
Quote
I then am little confused as to where to connect the power and ground of the arduino. Do i connect the ground to the emitter, and also to the ground of the NES? And then connect the power to the collector, and also to the 9V from the NES?

You don't connect ground to anything on the transistor, or the power to anything on the transistor. To use the transistor as a switch in its simplest form you need to saturate the transistor when its on, and have it at cutoff when its off. Basically, data pin through a resistor to the base like you said, and each contact of the "switch" would be an emitter or collector.

The thing you need to find out is what current you need through the base to get into saturation, which depends on your specific transistor, and not to exceed the Arduino's max output current.

Although, that said, transistors can't switch AC voltages. You said the power supply is 9V AC, so that might be an issue. That's probably why a relay was mentioned.
2  Using Arduino / Installation & Troubleshooting / Re: "...could not create a folder to store your sketchbook" HELP ME!! on: March 06, 2011, 07:24:29 am
Alrighty. When you unzipped the .zip, I think it unzipped it with a sketchbook folder. Try moving that somewhere else temporarily and launching your IDE.
3  Using Arduino / Programming Questions / Re: LED sensing on: March 06, 2011, 07:20:53 am
No, I think an analogue conversion on the AVR would be too slow for this.
In essence, you're measuring the discharge of a capacitor, so time is more important.

As an aside, it was an area I was fascinated by as a teenager, that many transducers could be used as sensors, like a loudspeaker used as a microphone.

Fair enough, but then comparing it to a value that's not high or low would be moot, I'd think.
4  Using Arduino / Programming Questions / Re: LED sensing on: March 06, 2011, 07:03:35 am
Quote
LEDs don't work in reverse
Sorry, but yes they can!

http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.69.1570&rep=rep1&type=pdf

You're not using the LED correctly - read the paper I linked, it is very good.

Wow, sorry, I had no idea. Either way I think he wants to use an analog pin rather than a digital pin, though.
5  Using Arduino / Installation & Troubleshooting / Re: "...could not create a folder to store your sketchbook" HELP ME!! on: March 06, 2011, 06:13:50 am
Run in admin mode and make sure the folder that your arduino software is in isn't read-only. Not sure if macs have that stuff but I assume they do.
6  Using Arduino / Programming Questions / Re: Serial Print All Values on: March 06, 2011, 06:02:40 am
Also when I try and do serial.print for an output, it displays the pin number instead of the output.  How can I change this?

As far as this goes, you have to do a read of the pin, then print it using the variable name you assign to the read. Or print the variable name you're using in the program. If you're trying to print the name of the pin itself, then all you're doing is showing the value you assigned to it at the beginning of your program; i.e., the pin number.
7  Using Arduino / Programming Questions / Re: LED sensing on: March 06, 2011, 05:53:10 am
LEDs don't work in reverse. Unless you're talking about something else, there's no way that will work. You need a photoresistor or a photodiode of some sort.

Also, if you're trying to take an input that's not either on or off (digital), you have to use one of the Analog pins. You can't analogRead from a digital pin.
8  Using Arduino / Programming Questions / Re: pulseIn question on: March 05, 2011, 11:00:02 pm
I checked boards.txt and the L is there. Everything else works fine, delays and all that (assuming that would be affected by what you're asking). Just pulseIn is capping.

Since I can't fix this, I made new code to replace pulseIn for my purposes.

Code:
void getHighPulse(){ //this is my replacement for pulseIn
  int currentMillis = millis(); //this saves the current milliseconds for later use
  while(pinStatus == HIGH){ //since this is high pulse, it waits until it goes low to move on
    pinStatus = digitalRead(wwvinput);
  }
  int newMillis = millis(); //this uses the milliseconds after it's low again for the next line
  pulseLength = newMillis - currentMillis;//this returns the length of the pulse (minus some microseconds due to clock cycles, but that's ok for this
  return;
}

and
Code:
void getLowPulse(){ //same as the above function, but for low pulses
  int currentMillis = millis();
  while(pinStatus == LOW){
    pinStatus = digitalRead(wwvinput);
  }
  int newMillis = millis();
  pulseLength = newMillis - currentMillis;
  return;
}

It won't have the precision that pulseIn has (since it's in milliseconds and I lose some time to clock cycles), but for pulses that are one of: 200ms, 500ms, or 800ms, this should do the trick.

Thanks for all the input! I've got an Arduino Duemilanove on the way to check if it's something wrong with my IDE/board or something, since pulseIn seems to work for other people just fine.
9  Using Arduino / Programming Questions / Re: pulseIn question on: March 05, 2011, 09:21:22 pm
Alrighty that's good to know, I'm not exactly an expert at any of this. That said, though, even using UL at the end it still doesn't affect the timeout. I can make the timeout lower, though, I think; if I set timeout to 1000 microseconds, it *looks* like it goes faster than a second. Higher doesn't work and the value returned cannot be higher than 200,000. If the variable that pulseIn is returning is unsigned long, can it not be higher than 200,000?
10  Using Arduino / Programming Questions / Re: pulseIn question on: March 05, 2011, 09:00:28 pm
No sir I was just doing that to keep the zeros apart in my head, the exact thing I wrote was
Code:
duration = pulseIn(pin, HIGH, 10000000UL)

or

Code:
duration = pulseIn(pin, LOW, timeout)

where timeout was
Code:
unsigned long timeout = 10000000

just in case.
11  Using Arduino / Programming Questions / Re: pulseIn question on: March 05, 2011, 05:31:10 pm
Yea I was assigning it as unsigned long. I didn't know I could do #UL, though, thanks!

Even 10,000,000UL yields a timeout of less than a second, and I still can't get anything to come out with a 1Hz signal. Using digitalread, I get high when it's high and low when it's low so the pin is seeing the changes, pulsein just doesn't work above 200,000 microseconds.
12  Using Arduino / Programming Questions / Re: pulseIn question on: March 05, 2011, 01:02:33 am
Sorry for the double post, but I have found a new, weird issue. After testing the pulseIn function extensively on my arduino, I've found two things.

1) The timeout field doesn't work. I can put anywhere from 1 to 1000000, and the timeout will still be the same.

2) The counting stops at 200,000 microseconds. Anything above that, and it returns zero consistently. However, if it was below 200,000 microseconds it was spot on. I had a function generator with a square wave 0-5V and the pulseIn function worked down to 3 microseconds. The high level (200,000 mentioned earlier) seemed heavily dependent on what I put in the timeout field, though. While timeout had no effect on the actual timeout, it seemed that if I entered 1000 into that field, it would only get up to about 60,000 microseconds. Once I increased timeout to 10,000,000, I was able to get up to 200,000 microseconds. 10,000,000 was the only number that had that sort of effect, though.

I really can't for the life of me figure out what's going on with it, and it's the basis of the program. Is it possible something's wrong with my arduino itself? I'm honestly dumbfounded. All delay() functions and those sorts of things work perfectly that I've seen, and I can run an LCD perfectly (which I think would be heavily dependent on timing from my short time with assembly language).
13  Using Arduino / Programming Questions / Re: pulseIn question on: March 03, 2011, 09:20:57 pm
Well, stripped down the program to just be pulseIn and serial prints and sent it pulses with a 555, and while it wasn't perfect, I think the variation was because I was pressing it during the pulse count, so it was catching the end of the pulses. When it caught the entire pulse, it seemed to be correct.

Thanks a lot guys, I changed my code to reflect the changes.
14  Using Arduino / Programming Questions / Re: pulseIn question on: March 03, 2011, 09:09:03 pm
Look at the manual for "pulsein()".  It returns MICROseconds, not MILLIseconds.

17000 microseconds is 17 milliseconds is 0.017 seconds.

I don't know how I missed that. I'm going to check again with a 555, I think my 8051 is acting up. Thanks a lot for alleviating a huge headache, though. I'm really sorry to waste your time on something so simple Graynomad.
15  Using Arduino / Programming Questions / Re: pulseIn question on: March 03, 2011, 08:15:09 pm
I connected the grounds together on the two microcontrollers and I'm still getting wildly varying numbers. They seem to stay relatively close (they don't normally jump more than 1000ms at a time), but they're still much much higher than the time it takes to return the value (over 10k milliseconds and the values are returned in less than a second).

The pulses are approximately 500ms. My understanding is that I should get a bunch of (approximately) 500 returns from the function. I could understand 300-800, if it was consistent in that ballpark I would work around it. The numbers I'm getting though are complete nonsense and I don't know why.

The part of the loop:
Code:
wwvpulselength = pulseIn(wwvinput, HIGH);
if (wwvpulselength > 950)
{ setbits();}

immediately goes to the function because any input whatsoever spikes the value of the pulseIn function to 8000ms at the least.

Also, thanks a lot for the help so far, I really appreciate it, for what it's worth.
Pages: [1] 2