-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
31 lines (27 loc) · 949 Bytes
/
Copy pathmain.cpp
File metadata and controls
31 lines (27 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//
// Toggle ATTiny85 (Toggle PORTB.PB4, pin 3)
//
// +-\/-+
// RESET / PB5 1 | | 8 Vcc
// CLKI / PB3 2 | | 7 PB2 / SCK
// CLK) / PB4 3 | | 6 PB1 / MISO
// Gnd 4 | | 5 PB0 / MOSI
// +----+
#include "Arduino.h"
#define LEDBIT (1 << 4) // PB4 (connected to LED to ground via 330 ohm resistor
#define INBIT (1 << 3) // PB3 (connected to pushbutton switch to gnd)
void setup() {
DDRB = LEDBIT; // Set PB4 as output, all others as inputs
PORTB = INBIT; // Set pullups on input pin PB3
}
void loop() {
while (true) {
PORTB |= LEDBIT; // Turn the LED On
delay(250);
PORTB &= ~LEDBIT; // Turn the LED Off
delay(250);
if ((PINB & INBIT) == 0) { // Check if switch pressed
__asm__ ("break\n\t"); // If so, return control to debugger
}
}
}