Tuesday, August 26, 2014

2014 Shen Qi - have attitudes technology blog Hebei ICP No. 11004217 sydney airport duty free -2


Switch (switch) in digital circuits is a basic input form, its role is to connect or disconnect the hold circuit. Arduino from the digital I / O pins only read high (5V) or low (0V), and therefore we first faced with a problem is how to switch on / off status sydney airport duty free can be read into Arduino high / low. The solution is to use the up / down resistors, generally can be divided according sydney airport duty free to the different positive logic circuit (Positive Logic) and negative logic (Inverted Logic) two kinds. sydney airport duty free
Corresponding code is: int ledPin = 13; int switchPin = 7; int value = 0; void setup () {pinMode (ledPin, OUTPUT); pinMode (switchPin, INPUT);} void loop () {value = digitalRead (switchPin ); if (HIGH == value) {digitalWrite (ledPin, LOW); // turn LED off} else {digitalWrite (ledPin, HIGH); // turn LED on}}
2014 Shen Qi - have attitudes technology blog Hebei ICP No. 11004217 sydney airport duty free -2 Suffusion theme by Sayontan Sinha

No comments:

Post a Comment