Advertisement
Charflow

Simpel test kode til kopanemometer

Apr 30th, 2017
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. long transistorValue = 0;
  2. int readingPort = 3;
  3.  
  4. void setup() {
  5.   // put your setup code here, to run once:
  6.   pinMode(readingPort, INPUT);
  7.   Serial.begin(9600);
  8. }
  9.  
  10. void loop() {
  11.   // put your main code here, to run repeatedly:
  12.   //transistorValue = digitalRead(readingPort);
  13.   transistorValue = pulseIn(readingPort, HIGH);
  14.   Serial.print(transistorValue);
  15.  
  16.   if(transistorValue){
  17.     Serial.print("    hole!");
  18.   }
  19.   else{
  20.     Serial.print("    no hole");
  21.   }
  22.   Serial.println(" ");
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement