Saturday, June 4, 2022

tinkercat motor and sensor


when object moves in detected area, motor spins
void setup()
{
  DDRD = 0b00100000;  //pin 5 output
  PCICR = 0b00000100;  //interrupt group 3
  PCMSK2 = 0b10000000; //pin 7 interrupt
  sei();
}

void loop()
{
 
}

ISR(PCINT2_vect){
PORTD ^= 0b00100000; //toggle pin 5
}

reference:

No comments:

Post a Comment