Hello!!
I've been working on this small project for weeks. Perhaps another set of eyes would see what I'm missing here.
What I'm trying to do is make a touch switch that controls a 5V 1A LED via a NPN mosfet.
In an attempt to shrink my project, I tought myself to program Attiny85's with my Arduino Leonardo.
After many tears and bent wires, I managed to program it successfully.
Or not....
After loading the program, I get no response initially when wiring 5V from my Leonardo pin and the Vin to my LED (simplified in my diagram)... After a minute or two, my LED begins to slowly light up as if on a dimmer and plateaus maybe at 75% brightness. What is going on here?!
Here is my coding. Excuse my wiring mess. Trying my best here as a mechanical guy:
#include <CapacitiveSensor.h>
CapacitiveSensor cs_0_1 = CapacitiveSensor(0,1); // 1M resistor between pins 0 & 1, pin 1 is sensor pin, add a wire and or foil
int touchCounter = 0; //Used in switch statement
int LED = 2; //LED pin 12 on arduino
void setup()
{
cs_0_1.set_CS_AutocaL_Millis(0xFFFFFFFF);// turn off autocalibrate on channel 1 - just as an example
//Serial.begin(9600);
pinMode(LED,OUTPUT);
}
void loop()
{
long sensor1 = cs_0_1.capacitiveSensor(50); //Reads sensor data
if(sensor1 >= 1000) //If sensor reads above a certain value
{
touchCounter++; // Switch statenebt
delay(100);
}
switch(touchCounter){
case 1: // Turn on LED
digitalWrite(LED1, HIGH);
break;
case 2: // Turn off LED
digitalWrite(LED1, LOW);
touchCounter = 0; //Reset counter to be repeated
break;
}
delay(250);
}
Hi,
Ops diagram.
Is the CapacitiveSensor library compatible with attiny85?
Also don't forget your 5V LED is not going to be very bright with 3.7V from Lipo.
What is the part number of your MOSFET?
Is it a logic level type?
Tom... 
The touch sensor connection is wrong. There should go one contact to Gnd, the other to an input pin and a resistor to another input pin.
TomGeorge:
Is the CapacitiveSensor library compatible with attiny85?
Also don't forget your 5V LED is not going to be very bright with 3.7V from Lipo.
What is the part number of your MOSFET?
Is it a logic level type?
Tom... 
At direct connection with LiPo battery is OK right now, good brightness... The MOSFET I'm using is a IRLZ44N. It's what I have, I'm sure there's better. Datasheet is here
I've seen a project online using the Attiny85, seemed to work well (seen here)
DrDiettrich:
The touch sensor connection is wrong. There should go one contact to Gnd, the other to an input pin and a resistor to another input pin.
I considered this, but this same code works excellently on my Leonardo.
Hi,
Have you tried the project in the link?
Looking at its code there is tuning to be done to establish the capacitance of the sensor.
A small sensor will have a small capacitance, not sure how small.
A large sensor will have a large capacitance, not sure how large.
So your project needs to be tuned to get the best response.
To quote the very last sentence in that project;
Another important thing with capacitive sensors is grounding.
Tom... 
I'll look at this and repost as soon as I get home! Thank you!
EDIT:
Went home and just moved some code around. Like Tom and Dr.Detrich say, it has something to do with electrical flow for the touch sensor, when you have a sensor, you might need to add and subtract resistance until it seems tuned. Or you can have the board average the values like in the blog link I posted.
Overall, great success! Thank you all!