If your circuit is behaving weirdly, switching on when you touch a wire or move your hand over the circuit you almost certainly have a floating input. You can solve this problem with a pull-up resistor. Many AVRs have built-in pull-up resistors that you can turn on using code.

In Sketch:

pinMode(2, INPUT_PULLUP);

In BascomAVR:

Config Portb.1 = Input Set Portb.1

There’s a great article at SparkFun about Pull-up Resistors.

  • MapleEngineerOPM
    link
    fedilink
    English
    arrow-up
    2
    ·
    1 year ago

    Very, very good point. I always put a 0.1uF cap between Vss and Vdd on my chips as close to the chip as I can get it.

    As I understand it many chip manufacturers specify what cap or caps you’re supposed to use for decoupling. I saw a video where the guy said that the manufacturer of the chip that he was talking about suggested a small ceramic like I use plus an electrolytic. I’ve never done that. I should probably look at the datasheets more often.

    Thanks for the comment!