Keyestudio 4WD Bluetooth Multi-functional Car Manual page 34

Hide thumbs Also See for 4WD Bluetooth Multi-functional Car:
Table of Contents

Advertisement

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

Advertisement

Table of Contents
loading

Related Products for Keyestudio 4WD Bluetooth Multi-functional Car

Table of Contents