Legal Removal Request This form is for reporting content posted on the AB Electronics UK forums that you believe violates your personal legal rights or applicable local laws for your country. Post: Hi Dave I tried your code and the interrupt is triggering but where your loop is repeating every 0.2 seconds it only flashed up on the screen for a fraction of a second before disappearing again so it was easy to miss. I have translated the interrupt demo from our python library to C. [pre][code]#include #include #include #include #include "ABE_IoPi.h" void clearscreen () { printf("\033[2J\033[1;1H"); } int main(int argc, char **argv) { setvbuf(stdout, NULL, _IONBF, 0); // needed to print to the command line // initialise one of the io pi buses on i2c address 0x20, default address for bus 1 IOPi_init(0x20); // Set all pins on the IO bus to be inputs with internal pull-ups enabled. set_port_pullups(0x20, 0, 0xFF); set_port_pullups(0x20, 1, 0xFF); set_port_direction(0x20, 0, 0xFF); set_port_direction(0x20, 1, 0xFF); // Invert both ports so pins will show 1 when grounded invert_port(0x20, 0, 0xFF); invert_port(0x20, 1, 0xFF); // Set the interrupt polarity to be active high and mirroring disabled, so // pins 1 to 8 trigger INT A and pins 9 to 16 trigger INT B set_interrupt_polarity(0x20, 1); mirror_interrupts(0x20, 0); // Set the interrupts default value to 0x00 so the interrupt will trigger when any pin registers as true set_interrupt_defaults(0x20, 0, 0x00); set_interrupt_defaults(0x20, 1, 0x00); // Set the interrupt type to be 1 for ports A and B so an interrupt is // fired when the pin does not match the default value set_interrupt_type(0x20, 0, 0xFF); set_interrupt_type(0x20, 1, 0xFF); // Enable interrupts for all pins set_interrupt_on_port(0x20, 0, 0xFF); set_interrupt_on_port(0x20, 1, 0xFF); while (1){ // read the interrupt status for each port. // If the status is not 0 then an interrupt has occured on one of the pins // so read the value from the interrupt capture. if (read_interrupt_status(0x20, 0) != 0){ printf("Port 0: %x \n", read_interrupt_capture(0x20,0)); } if (read_interrupt_status(0x20, 1) != 0){ printf("Port 1: %x \n", read_interrupt_capture(0x20,1)); } usleep(200000); // sleep 0.2 seconds } return (0); }[/code][/pre] The difference between this and your code is I changed the interrupt type to be 1 on each pin so it will fire when the pin does not match the default value and I changed the while loop so on each loop the interrupt status for each port is checked and it only prints the result if the interrupt has fired. I used the read_interrupt_capture() function to get the value of the interrupt when it fired and print that to the display. When the code runs it will print the status repeatedly when a pin is connected to ground. If you only want it to print when the pin state changes change the set_interrupt_type(0x20, 0, 0xFF); to set_interrupt_type(0x20, 0, 0x00); I have uploaded a copy of the c code to our GitHub repository at [url=https://github.com/abelectronicsuk/ABElectronics_C_Libraries/blob/master/IOPi/demos/demo-iopiinterrupt.c]demo-iopiinterrupt.c[/url] Select the country where you are claiming legal rights. Albania Algeria American Samoa Andorra Angola Anguilla Antarctica Antigua and Barbuda Argentina Aruba Australia Austria Bahamas Bahrain Bangladesh Barbados Belarus Belgium Belize Benin Bermuda Bhutan Bolivia Bosnia And Herzegovina Botswana Bouvet Island Brazil British Indian Ocean Territory British Virgin Islands Brunei Bulgaria Burkina Faso Burundi Cambodia Cameroon Canada Canary Islands Cape Verde Cayman Islands Central African Republic Chad Channel Islands Chile Christmas Island Cocos (Keeling) Islands Colombia Comoros Congo Cook Islands Costa Rica Croatia Cuba Cyprus Czech Republic Denmark Djibouti Dominica Dominican Republic East Timor Ecuador Egypt El Salvador Equatorial Guinea Estonia Ethiopia Falkland Islands (Malvinas) Faroe Islands Federated States of Micronesia Fiji Finland France French Guiana French Polynesia French Southern Territories Gabon Gambia Georgia Germany Ghana Gibraltar Greece Greenland Grenada Guadeloupe Guam Guatemala Guyana Haiti Heard Island and McDonald Islands Honduras Hong Kong Hungary Iceland India Indonesia Ireland Israel Italy Jamaica Japan Jordan Kazakhstan Kenya Kiribati Kuwait Kyrgyzstan Laos Latvia Lesotho Liechtenstein Lithuania Luxembourg Macau Macedonia Madagascar Malawi Malaysia Maldives Mali Malta Marshall Islands Martinique Mauritania Mauritius Mayotte Mexico Micronesia, Federated States Of Moldova, Republic Of Monaco Mongolia Montenegro Montserrat Morocco Mozambique Myanmar Namibia Nauru Nepal Netherlands Netherlands Antilles New Caledonia New Zealand Nicaragua Niue Norfolk Island Northern Mariana Islands Norway Oman Palau Panama Papua New Guinea Paraguay Peru Philippines Pitcairn Poland Portugal Puerto Rico Qatar Reunion Romania Russia Rwanda Samoa San Marino Sao Tome and Principe Saudi Arabia Serbia Seychelles Singapore Slovakia Slovenia Solomon Islands South Africa South Georgia and the South Sandwich Islands South Korea Spain Sri Lanka St. Helena St. Kitts and Nevis St. Lucia St. Pierre and Miquelon St. Vincent and the Grenadines Suriname Svalbard and Jan Mayen Islands Swaziland Sweden Switzerland Syria Taiwan Tajikistan Tanzania Thailand Togo Tokelau Tonga Trinidad and Tobago Tunisia Turkey Turkmenistan Turks and Caicos Islands Tuvalu U.S. Virgin Islands Uganda Ukraine United Arab Emirates United Kingdom United States United States Minor Outlying Islands Uruguay Uzbekistan Vanuatu Vatican City Venezuela Vietnam Wallis and Futuna Islands Western Sahara Yemen Yugoslavia Zambia What legal issue or problem do you wish to report? Please select Privacy / Erasure under GDPR Defamation Intellectual Property Hate Speech Other Please enter the following information so we can process your report. Contact Name: Contact Email: Details of complaint: Submit Complaint