Leo-zhong
Published © GPL3+

Runaway Spider

This spider will keep quiet in the night. But once there is light, the spider will start to vibrate, avoiding the light.

BeginnerFull instructions provided2 hours2,628

Things used in this project

Hardware components

Seeed Studio Seeeduino XIAO
×1
Grove - Light Sensor
Seeed Studio Grove - Light Sensor
×1
Grove - Vibration Motor
Seeed Studio Grove - Vibration Motor
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

Code

C/C++
const int lightPin = 2; 
const int motor =  3;     

int lightState = 0;         

void setup() {
  pinMode(motor, OUTPUT);
  pinMode(lightPin, INPUT);
}

void loop() {
  lightState = digitalRead(lightPin);
  if (lightState == HIGH) {
    digitalWrite(motor, HIGH);
  } else {
    digitalWrite(motor, LOW);
  }
}

Credits

Leo-zhong

Leo-zhong

2 projects • 2 followers

Comments