add macro for leds

This commit is contained in:
hugogogo
2025-03-04 12:06:40 +01:00
parent 7c2e96d72e
commit 8829366ff2

View File

@@ -5,6 +5,11 @@
#define TEST(REGISTER, BIT) REGISTER & 1 << BIT
#define TOGGLE(REGISTER, BIT) REGISTER ^= 1 << BIT
#define D1 0
#define D2 1
#define D3 2
#define D4 4
int main()
{
// DDRx : select direction of the pin
@@ -20,18 +25,17 @@ int main()
// PINx :
// turn on led 1
SET(DDRB, 0); // make PB0 as OUTPUT
SET(PORTB, 0); // make PB0 as HIGH (LED turns ON)
SET(DDRB, D1); // make PB0 as OUTPUT (pullup is off)
CLEAR(PORTB, D1); // make PB0 as HIGH (LED turns ON)
// CLEAR(DDRB, 1); // make PB0 as INPUT
// SET(PORTB, 1); // make PB0 pullup on
// SET(DDRB, D2); // make PB1 as OUTPUT (pullup is off)
// CLEAR(PORTB, D2); // make PB1 as LOW (LED turns OFF)
// SET(DDRB, 2); // make PB0 as OUTPUT
// CLEAR(PORTB, 2); // make PB0 as LOW (LED turns OFF)
// CLEAR(DDRB, D3); // make PB2 as INPUT
// SET(PORTB, D3); // make PB2 pullup on
// CLEAR(DDRB, 4); // make PB0 as INPUT
// CLEAR(PORTB, 4); // make PB0 as LOW (LED turns OFF)
// CLEAR(DDRB, D4); // make PB4 as INPUT
// CLEAR(PORTB, D4); // make PB4 pullup off
return 0;
}