Introduction: Multiple PICAXE Interrupts

Picture of Multiple PICAXE Interrupts

This Instructable tells you how to set up multiple picaxe interrupts.

You will need:
1 x PICAXE chip (any), I will draw a circuit diagram for a 14M
2 x diode
2 x switch
1 x LED
1 x 330R resistor
3 x 10K resistor
1 x 22K resistor
1 x 3.5 mm serial plug
1 x PICAXE programming cable + software
breadboard/verroboard
some wire

Step 1: Make Circuit to Program Chip

Picture of Make Circuit to Program Chip

To program the chip, build the circuit below:

Connect the serial in on the chip to a 22K resistor.
Connect a 10K resistor to the end of this.
Connect the joint to section "B" on the jack.
Connect the 10K resistor to negative.
Connect part "C" of the jack to negative.
Connect serial out on the chip to the centre pin ("A") on the jack.
Connect the chip to positive and negative.

Step 2: Set Up Inputs

Picture of Set Up Inputs

To connect the two switches:

Connect one side of the switch to positive.
Connect the other side of the switch to a 10K resistor, then to negative.
Connect the joint between the switch and the resistor to an input pin.
Connect the joint between the switch and the resistor to a diode, then to a spare input pin.

Repeat this for both switches, but connect the ends of the diodes to the same input.

Step 3: Connect the LED

Picture of Connect the LED

To connect the LED:
Connect the LED to an output pin.
Connect the other end to a 300R resistor.
Connect the other end of the resistor to negative.

Step 4: Program

Picture of Program

Connect the circuit to a computer, and open the programming software. Enter the following code: (This code is for the circuit in the diagram below)


setint %00001000,%00001000

main:
goto main

interrupt:
high 5
pause 5000
low 5
setint %00001000,%00001000
return



Below is what the code means:

setint %00001000,%00001000
This code sets an interrupt for pin 3, which is connect to both switches by diodes.

main:
This is a label for a routine named "main"

goto main
This runs the routine "main". These two lines of code constantly loop, doing nothing. This is to show the interrupt.

interrupt:
This is a label for a subroutine called "interrupt", which is run when pin 3 is triggered.

high 5
This sets pin 5 (connected to the LED) to high, which turns on the LED.

pause 5000
This tells the code to wait for 5000 milliseconds (5 seconds) before continuing.

low 5
This sets pin 5 to low, which turns off the LED.

setint %00001000,%00001000
This renables the interrupt again, because it is disabled when it is triggered.

return
This tells the code to return to the point at which the subroutine was activated (when either switch was pressed)
 

Step 5: Test

When you press either switch, the LED should turn on for 5 seconds, then off again.

Comments

About This Instructable

7,848views

7favorites

More by AntMan232:PICAXE Raspberry Pi ADCRaspberry Pi I2C (Python)Arduino stepper motor and servos shield - AW GCSE Board
Add instructable to: