Hackster is hosting Hackster Holidays, Ep. 7: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 7 on Friday!
Sheng Su
Published © Apache-2.0

Object detection and obstacle avoidance

Install the objects on the door, and when someone comes, the lights inside will light up to remind the people inside to open the door.

BeginnerProtip5 hours117
Object detection and obstacle avoidance

Things used in this project

Hardware components

Seeed XIAO BLE nRF52840 Sense
Seeed Studio Seeed XIAO BLE nRF52840 Sense
×1
Seeeduino XIAO Expansion board
Seeed Studio Seeeduino XIAO Expansion board
×1
Seeed Studio Grove - Green LED
×1
Seeed Studio Grove - Line Finder v1.1
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

demo.ino

C/C++
//------------------------------------------------------------
//Name: Line finder digital mode
//Function: detect black line or white line
//Parameter:   When digital signal is HIGH, black line
//             When digital signal is LOW, white line
//-------------------------------------------------------------
int signalPin =  D5;    // connected to digital pin D1
void setup()   {
  pinMode(D0, OUTPUT);
  pinMode(signalPin, INPUT); // initialize the digital pin as an output:
  Serial.begin(9600);  // initialize serial communications at 9600 bps:
}
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop()
{
  if(digitalRead(signalPin))
  digitalWrite(D0, LOW);   
  else  
   digitalWrite(D0, HIGH);   // display the color
  delay(1000);                  // wait for a second
}

Credits

Sheng Su
1 project • 0 followers

Comments