Sample Code:
*******************************************************************************
const int sensorPin = 3;
// the number of the sensor pin
const int ledPin = 13;
// the number of the LED pin
int sensorState = 0;
// variable for reading the sensor status
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(sensorPin, INPUT); }
void loop(){
// read the state of the sensor value:
sensorState = digitalRead(sensorPin);
// if the sensorState is HIGH:
if (sensorState == HIGH) {
digitalWrite(ledPin, HIGH);
}
else {digitalWrite(ledPin, LOW);
}}
*******************************************************************************
Result
After power-on, power indicator D1 is on. When you block the sensing part of line tracking sensor with black paper, LED on the sensor is off as shown in
When you block it with white paper, LED is on as shown in
keyestudio
Figure 2
.
www.keyestudio.com
Figure 1
.
32
Need help?
Do you have a question about the 4WD Bluetooth Multi-functional Car and is the answer not in the manual?