Basic Touching Control Using Sensors

1,446

45

3

Published

Introduction: Basic Touching Control Using Sensors

this is a really fundamental touching detect powered by a sensor and a AtTiny 85 board which i just got from my pal.

hope you enjoy it.

Step 1: To Prepare a Suitable Board and Download Its Pinout

i got a AtTiny 85 board occasionally from my friend, it is very very tiny, as shown in the picture with a red light on. but the pity is that it hasn't got that many pinout, not enough to make a temperature control board.

you could see how its pins work and then go to the next step.

Step 2: Sensor Is Needed to Detect Touching Event

this is a touching sensor, which is also pretty mini. so it matches the size of the AtTiny 85 board well.The light that alarms touching event is the LED on the AtTiny 85.

Step 3: The Code Part

int buttonState = 0;

// the setup routine runs once when you press reset:

void setup() {

// initialize the digital pin as an output.

pinMode(0, INPUT);

pinMode(1, OUTPUT); //LED on Model A OK

}

// the loop routine runs over and over again forever:

void loop() {

int i;

buttonState = digitalRead(0);

// check if the pushbutton is pressed.

// if it is, the buttonState is HIGH:

if (buttonState == HIGH) {

// turn LED on:

digitalWrite(1, HIGH);

}

else {

// turn LED off:

digitalWrite(1, LOW);

}

}

well, this is the code. And almost forget that the function of the sensor is : when touched(touch event detected) ,SIG output a 1, and when the object moves out of its range, output 0,the code above is to connect it with the pin,(PB0).

Step 4: The Result

that's it, a basic touching detect powered by sensor and AtTiny 85 (of course the code), you could see that once the hand is on the sensor, the light is on, and when nothing above, it is off. thanks for watching guys.

Share

    Recommendations

    • Water Contest

      Water Contest
    • Clocks Contest

      Clocks Contest
    • Oil Contest

      Oil Contest

    3 Discussions

    hahaha, is this an ad? looks like it,while i do hear people talk about some Asian products with bad quality, but i never meet one. How lucky.

    this inst. is good, wondering would there be any short videos?

    no it is not an ad, just an how to on fixing something i bought at an asian webstore. My experience with asian webstores on a whole is pretty good actually. This touch switch was in fact of good quality as well... I guess they just forgot a small print trace. In the feedback of that product i saw many people complain it didnt work, so must have been a production error. After a small blob of solder it worked perfectly