Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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