Go Down

Topic: Code form Uno don't work on Mega 2560 (Read 100 times) previous topic - next topic

AdamK24

Hello
I need help. I want to make this
https://www.instructables.com/id/How-to-Build-a-Bi-Fuel-LPG-Unleaded-Trip-Computer-/
but i want to do it on arduino mega, beacuse i want to add few more temp sensors and other stuff.
I can upload sketch witchout problem but then nothings happend, only black screen.
i think that it can be problem with PinChangeInterrupt librrery, that only my suspiciousys.
Sorry for my bad English.

groundFungus

I would try to help but I can't run the IDE on my device and am reluctant to download code.  If you post your code as described in the how to use this forum-please read stickies, everyone can see the code and, perhaps, offer assistance.

PaulS

Not all pins on the Mega support pin change interrupts. The SoftwareSerial reference page has a list of pins that do support pin change interrupts. You need to use a pin that does.
The art of getting good answers lies in asking good questions.

Geek Emeritus

#3
Apr 24, 2019, 08:00 pm Last Edit: Apr 24, 2019, 08:03 pm by Geek Emeritus
the guy who wrote the code needed that library because the UNO has 2 hardware interrupt pins. the Mega has 21.

Quote
Pinchange Interrupt Pins:

Digital Pin 0,22,23,24,25,10,11,12,13,15,14

Analog Pin 6,7,8,9,10,11,12,13,14,15

This pin is used for pin change interrupt. Enable bit of pinchange interrupt must be set with global interrupt enable.

Application :

Rotary encoder, push button based interrupt and others.

Example :

pinMode(0, OUTPUT);

pinMode(1, INPUT_PULLUP);

attachInterrupt(digitalPinToInterrupt(1), LOW, CHANGE);


from Arduino Mega Tutorial

remove that PinChangeInterrupt library and use hardware interrupts
All PMs will be deleted unopened due to arrogant argumentative pot stirring Malfoys.
 If you have not read "How to use this forum - please read", in particular: "7. If you are posting code or error messages, use "code" tags":  expect rude responses

PaulS

the guy who wrote the code needed that library because the UNO has 2 hardware interrupt pins. the Mega has 21.

from Arduino Mega Tutorial

remove that PinChangeInterrupt library and use hardware interrupts
You need to read that a bit closer, I think.

There are FIVE external interrupts. The highest pin number with an external interrupt is 21.
Quote
External Interrupts: 2 (interrupt 0), 3 (interrupt 1), 18 (interrupt 5), 19 (interrupt 4), 20 (interrupt 3), and 21 (interrupt 2). These pins can be configured to trigger an interrupt on a low level, a rising or falling edge, or a change in level. See the attachInterrupt() function for details.
The art of getting good answers lies in asking good questions.

AdamK24

#5
Apr 24, 2019, 08:25 pm Last Edit: Apr 24, 2019, 08:29 pm by AdamK24
I can't poste  a code beacouse it has more than 9000 characters

Quote
I would try to help but I can't run the IDE on my device and am reluctant to download code.  If you post your code as described in the how to use this forum-please read stickies, everyone can see the code and, perhaps, offer assistance.
Removing Pin Change Interrupt library from code seems too difficult for me  right now, maybe there is simpler way?

Go Up