|
Edited by Impressive at 2016-2-17 17:30
So, I tried to use pull-up and pull-down resistor in this C code, but it didn't work:
- #include <wiringPi.h>
- #include <stdio.h>
- #include <drcSerial.h>
- int main (void)
- {
- wiringPiSetup();
- pinMode(6, OUTPUT);
- pinMode(7, OUTPUT);
- pinMode(8, INPUT);
- digitalWrite(7, HIGH);
- pullUpDnControl (8, PUD_DOWN) ;
- if (digitalRead(8) == HIGH)
- {
- digitalWrite(6, HIGH);
- delay(500);
- digitalWrite(6, LOW);
- delay(500);
- digitalWrite(6, HIGH);
- delay(500);
- digitalWrite(6, LOW);
- delay(500);
- }
- else
- {
- digitalWrite(6, HIGH);
- delay(2500);
- digitalWrite(6, LOW);
- delay(500);
- }
- return 0;
- }
Copy code It's a LED
- pinMode(7, OUTPUT);
- pinMode(8, INPUT);
Copy code Beetwen this pins I puts the button.
So, when I switch button on/off it didn't work. LED flashed at random. I hope someone will find out how to deal with pin INPUT and button... |
|