ATtiny85 to control three 12V LED strips using TIP122

I am planning on using a ATtiny85 to control 3 separate 12V LED strips (each strip has built in resistors to control current).

Everything is powered from one 12V 5A power supply. A 5V voltage regulator is used to supply 5v power to the ATtiny85 and the PIR motion sensor. The output from the sensor (3.3VDC) is sent to PB2 on the ATtiny85, and this starts turning on the three 12V LED strips at different intervals using PWM output on PB0, PB1, and PB4.

Should I use digital read (high/low) or analog read for PB2 since the sensor outputs 3.3VDC?

I have programing experience in Arduino but this is my first ATtiny project.


This is the basic code that I am going to use. I know I have to declare & add the input for PB2.

/* Three PWM Outputs */
// ATtiny85 outputs
const int LEDone = 0;
const int LEDtwo = 1;
const int LEDthree = 2;
volatile uint8_t* Port[] = {&OCR0A, &OCR0B, &OCR1B};
int Pin[] = {0, 1, 4};
void setup() {
pinMode(Pin[LEDone], OUTPUT);
pinMode(Pin[LEDtwo], OUTPUT);
pinMode(Pin[LEDthree], OUTPUT);
// Configure counter/timer0 for fast PWM on PB0 and PB1
TCCR0A = 3<<COM0A0 | 3<<COM0B0 | 3<<WGM00;
TCCR0B = 0<<WGM02 | 3<<CS00; // Optional; already set

// Configure counter/timer1 for fast PWM on PB4
GTCCR = 1<<PWM1B | 3<<COM1B0;
TCCR1 = 3<<COM1A0 | 7<<CS10;
// Sets light LEDone=0 LEDtwo=1 LEDthree=2 to specified intensity 0 (off) to 255 (max)
void SetLight (int light, int intensity) {
*Port[light] = 255 intensity;
void loop() 
for (int light=0; light<3; light++) 
SetLight((light+2) % 3, 0);
for (int i=0; i <= 255; i++) {
SetLight((light+1) % 3, i);
SetLight(light, 255i);

Please use code tags (</> button on the toolbar) when you post code or warning/error messages. The reason is that the forum software can interpret parts of your code as markup, leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier to read your code and to copy it to the IDE or editor. Using code tags and other important information is explained in the How to use this forum post. Please read it.

Please always do a Tools > Auto Format on your code before posting it. This will make it easier for you to spot bugs and make it easier for us to read. If you’re using the Arduino Web Editor you will not have access to this useful tool. I recommend you to use the standard IDE instead.

Use digitalRead(), anything over 2.5 V will be seen as a HIGH so 3.3 V is fine.