Could it Possible to map hardware Interrupt on P3^2 () to pin P3^1 so when I press Switch on P3^1 Interrupt starts and make toggle the LED
Here is the Code :
But some how its for Switch 3 / Interrupt on Pin P3^2 so upon pressing switch 3 Interrupt occur and toggle led , but I want that upon pressing the Switch K1 the LED starts toggle
Code :
Here is the Code :
But some how its for Switch 3 / Interrupt on Pin P3^2 so upon pressing switch 3 Interrupt occur and toggle led , but I want that upon pressing the Switch K1 the LED starts toggle
Code :
Code:
#include<reg51.h>
sbit LED = P2^0; // LED at P2.0
void delay_ms(unsigned int ms) {
unsigned int i, j;
for (i = 0; i < ms; i++) {
for (j = 0; j < 120; j++)
{
}// Approx 1ms delay in 8051 with 11.0592 MHz Crystal
}
}
void ISR_External0(void) interrupt 0 // ISR for External Interrupt 0
{
LED = ~LED;
delay_ms(300);
}
void main()
{
EA = 1; // Enable Global Interrupts
EX0 = 1; // Enable External Interrupt 0
IT0 = 1; // falling edge // whwen we hold leds it will lock the state not blinking the leds // while IT0 = 0 makes blinking
// Because in low-level mode:
// The interrupt is active the entire time the pin is LOW (0) IT0 = 0 // while IT0 = 1 detect one event per press
// It stops only when the pin goes back to HIGH (1) //
LED = 0; // LED ON Initially // common anode mode // Anode is connected to Vcc of all leds
while(1)
{
}
}
Last edited by a moderator: