EasyManua.ls Logo

Keyestudio 4WD Bluetooth Multi-functional Car - Page 34

Keyestudio 4WD Bluetooth Multi-functional Car
151 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
keyestudio
www.keyestudio.com
32
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 Figure 1.
When you block it with white paper, LED is on as shown in Figure 2.

Related product manuals