Go Down

Topic: Button triggered Macro, problems with interrupt and delay (Read 1 time) previous topic - next topic

twistedsymphony

this is what I'm getting output to the serial monitor... which is exactly what I'd expect:
Quote
seq 0: 10000000000000000000001111101000
seq 1: 1000000000000000000001111101000
seq 2: 100000000000000000001111101000
seq 3: 10000000000000000001111101000
seq 4: 1000000000000000001111101000
seq 5: 100000000000000001111101000
seq 6: 10000000000000001111101000
seq 7: 1000000000000001111101000
seq 8: 100000000000001111101000
seq 9: 10000000000001111101000
seq 10: 1000000000001111101000


PaulS

Code: [Select]
int pin_B = 0;
int pin_X = 1;

These are the serial pins, you know. If you are doing Serial I/O (and you are), you can't expect to use them with LEDs, too.

Quote
when I run my new function instead, which loops through an array and should be doing the exact same thing as "doStuff" the pin for pin_B, and pin_X don't work...

Well, I'm not surprised.

twistedsymphony

#17
Dec 30, 2012, 02:51 pm Last Edit: Dec 30, 2012, 04:02 pm by twistedsymphony Reason: 1

Code: [Select]
int pin_B = 0;
int pin_X = 1;

These are the serial pins, you know. If you are doing Serial I/O (and you are), you can't expect to use them with LEDs, too.

I'm not using them to drive LEDs they're integrated with a USB game controller the game controller simply needs a logic high or logic low.
I know when the Arduino is "pushing" a button because I have the controller plugged into my computer with a simple test program that shows when a button is being pushed.

Quote
when I run my new function instead, which loops through an array and should be doing the exact same thing as "doStuff" the pin for pin_B, and pin_X don't work...

Well, I'm not surprised.

I still don't understand, maybe you could explain to me why these outputs work as desired when I call
"digitalWrite(pin_B, LOW);" in the "doStuff" function but not when I call
"digitalWrite(pin_B, LOW);" in the "runSeq" function.

PaulS

Quote
I still don't understand, maybe you could explain to me why these outputs work as desired when I call
"digitalWrite(pin_B, LOW);" in the "doStuff" function but not when I call
"digitalWrite(pin_B, LOW);" in the "runSeq" function.

In the code that calls doStuff, you do not have an instance of the Serial class using pins 0 and 1. In the runSeq code, you do. Pins 0 and 1 can be used for general I/O OR serial. They can not be used for both.

twistedsymphony

AHH! thank you thank you!

I didn't realize that those serial commands used the actual serial O/I pins, I thought it was just using the USB port as a serial interface, now it all makes sense.

Nick Gammon

The main processor doesn't have a USB port, so it uses the two serial pins to reach the USB interface chip.
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

Go Up