Created
January 13, 2021 17:33
-
-
Save alvesoaj/3ca6182905fa4504489fb9b929eb995b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int ledPin = 13; // Arduino' inner led | |
int sigPin = 4; // For sensor signal | |
int value = 0; // Holds the returned value | |
void setup(){ | |
Serial.begin(9600); | |
pinMode(ledPin, OUTPUT); // Arduino's led as output | |
pinMode(sigPin, INPUT); // signal pin as input | |
} | |
void loop(){ | |
value = digitalRead(sigPin); // Read the sensor | |
if (value == HIGH) { // iF HIGH, black area | |
digitalWrite(ledPin, HIGH); // Turn on the LED | |
Serial.write("Black"); // Write on console | |
} else { // Else, white area | |
digitalWrite(ledPin, LOW); // Turn off the LED | |
Serial.write("White"); // Write on console | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment