“Lesson 16--Microduino "Fingertip switch (transistor trigger)"”的版本间的差异

来自Microduino Wikipedia
跳转至: 导航搜索
Pkj讨论 | 贡献
第1行: 第1行:
{{Language|Lesson_16--Microduino_"Fingertip_switch_(transistor_trigger)}}
+
{{Language|Lesson_16--Microduino_"Fingertip_switch_(transistor_trigger)"}}
 
{| style="width: 800px;"
 
{| style="width: 800px;"
 
|-
 
|-

2014年3月2日 (日) 14:33的版本

Language English

Objective

Maybe you hit that sometimes accidentally touch the led will light up in the experiment. That is because the human body resistance to leds light up. During DIY phototransistor, as long as give in a samll voltage to NPN transistor's base,the triode will be connected, achieve the purpose of the switch, so today we are going to do a fingertip switch, use the human body resistance to light the led.

Equipment

  • Microduino-Core
  • Microduino-FT232R
  • Other hardware equipment
    • Breadboard Jumper one box
    • Breadboard one piece
    • LED Light-emitting diodes one
    • 10k,1k,220Ω resistor one
    • 9014 triode one
    • USB Data cable one

Experimental schematic

Lesson16-schematic.jpg

Human body resistance connects to VCC,and the other end connects the transistor's base. The principle is the same with principle diagram of lesson 12, so not in detailed again.

Program

void setup()
{
  Serial.begin(115200);
  pinMode(13,OUTPUT);  
}
void loop()
{
  int n=analogRead(A0);   //Read data from analog port        
  if(n>0)     //If the voltage changed,then run following program
    digitalWrite(13,HIGH); //Turn on the led
  else
    digitalWrite(13,LOW); //Turn off the led
  Serial.println(n);//Use seiral to monitor
  delay(100);//delay 100ms for refresh the data
}

Result

Contact with human body resistance at both ends with the hand, LED light, once loose, the LED goes ff. You can try to do a touch switch?

Video