I have a 2560 mega based custom board and need to use pin 36 as an interrupt so that I can set is as a Receive port (using SoftwareSerial) to talk to another Arduino board.
I know that the ATMEGA2560 (and other Arduino chips) support any pin being an Interrupt. I found this Arduino Playground - PcInt but am at a loss for how to make pin 36 an interrupt.
Half of the analog pins have interrupts, if I configure one as a digital pin will that also work? Suggestions?
Those ints are per port so 8 digital IO's and you can mask off the others. Yea you can do it but there has to be a better way have you considered I2C, SPI or one of the 4 hardware uarts? rather than soft serial.
I just realized that I do have D17 available on the custom board and its a hardware serial receive. I can use any digital pin as the TX for hardware serial, right?
Looks like that's not going to work. So either I do SoftwareSerial or I use I2C on both Arduinos (the pins are open). Is there an advantage to I2C over Software serial?
I2C is done in hardware, SoftwareSerial is done in software. Anything implemented in software will consume more resources.
chrishjones:
I just realized that I do have D17 available on the custom board and its a hardware serial receive. I can use any digital pin as the TX for hardware serial, right?
Well you could technically use soft serial send on any port but D16 would be the hardware one that matches otherwise your receiving on one serial port and sending on another besides being ugly it should work. Are you using the mega unmapped pins pe2,pe6,pe7,pg3,pg4,pd6,pd5,pd4,pj7.pj6,pj5,pj4,pj3,pj2,ph7,ph2 I think 7 or so of them are hardware ints as well.
I2C is a good deal faster than serial and it's implemented in hardware. It's also multi drop so you can also connect sensors, eeprom, IO ex-panders, etc still using just those 2 pins. Since you seem to be running low on IO pins those IO ex-panders might be useful.
You did not mention what you wanted to connect the two atmega's together I assume it's not for increased processing speed.
The Mega2560 has quite a few hardware serial pins, you know.
Pins 14, 15, 16, 18, 19 are taken by Motor drivers, it's hardwired on the board, the pins aren't even exposed.
I'm connecting a second 2560 to drive a 3" LCD and touchpanel and it uses pins 22-53. I may also connect a 9DOF IMU to it because the custom board has its hands full with 5 analog pressure sensors, 5 LEDs and 3 motor drivers (which will likely increase to 5) and 3 rotary absolute position sensors. The main board is being connected to Ubuntu running ROS (Robot Operating System), it will be making all the decisions based on sensor data on when to turn on LEDs and motors.
silasmoeckel, the only pin that has an interrupt that is free is D17, all the rest are hardwired to other things. I don't think I could do hardware serial for just RX and softwareserial for the TX?
Seems like I2C is probably my best bet. I'll play with it tonight and see if I can get it working. 2 Arduinos Talking How-To I2C / TWI - YouTube - this is a tutorial I found but haven't watched yet.