I've got a circuit that's not acting as I suspected it would. It's a very simple circuit (simplified from my initial, a bit more complex circuit just because I couldn't understand the error).
So it's an ATTiny85, connected to an analog accelerometer outputting x,y, and z axis as a voltage between 0 and 3.3V. Input voltage to the whole circuit is 5V. I'm only using the Y-axis measurement of the accelerometer. There are two pins that go to an external board with a resistor and a LED diode.
I'm measuring voltage with ADC on PB4 and sending out the current for the LED on PB3.
When I run the code, everything seems to work fine. I have set it to turn on PB3 when the ADC measures a voltage over a certain treshold. So I connect it to power, LED is off, I lift the device up and shake it along the Y-axis, LED turns on.
But! It's supposed to turn off after the voltage is measured below the treshold again! Even when I put it down on the table again, the diode is still shining.
At this point, I thought something was strange with the connection and for some reason short circuiting the ATTiny, but i checked with the multimeter and even when the LED is on, the ATTiny has 5 volts over it.
I thought something was wrong with the accelerometer, so I changed the code and just wanted it to turn off and on the LED on PB3. I set it do delay 1s after turning on the ATTiny before it turns on the LED, then another second delay, lastly turn off the diode again. It seems to delay when I plug it in, then turn on the LED, then it gets stuck again!
I've attached pictures of my circuit, one of the front and one on the back. The squares show the components, lines show power and ground, dashed lines means that the connection is by wire on the front.
Here's to hoping you guys can find my fault.