» Topics » Advice »Spider running away from the light

Spider running away from the light



An interesting and funny toy on the microcontroller was invented and made by the Master. This is a spider that is at rest in the dark, but if a ray of light falls on it, it tries to escape. To make such a toy, the master used a minimum of details.
-Microcontroller Seeeduino XIAO;
-Vibromotor;
-Light sensor;
-Resistors (for legs);
-Source of power;

Of the tools you need soldering accessories and wire cutters.
Let's see how the device works.

For power supply, the microcontroller needs 3.3 V. When assembling, you need to correctly position the parts, taking into account balancing.

The master makes legs from resistors.


After the assembly, you need to download the code.
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);
}
}


All is ready. Now you need to install the spider on a flat surface, turn on the power and turn off the light. When the light beam is directed at the photoresistor, the vibromotor starts to work, and the spider slides to the side on its thin legs.

Suitable for topic

Related topics

Add a comment

    • smilesmilesxaxaokdontknowyahoonea
      bossscratchfoolyesyes-yesaggressivesecret
      sorrydancedance2dance3pardonhelpdrinks
      stopfriendsgoodgoodgoodwhistleswoontongue
      smokeclappingcraydeclarederisivedon-t_mentiondownload
      heatirefullaugh1mdameetingmoskingnegative
      not_ipopcornpunishreadscarescaressearch
      tauntthank_youthisto_clueumnikacuteagree
      badbeeeblack_eyeblum3blushboastboredom
      censoredpleasantrysecret2threatenvictoryyusun_bespectacled
      shokrespektlolprevedwelcomekrutoyya_za
      ya_dobryihelperne_huliganne_othodifludbanclose
2 commentary
There is such a suspicion ...
Spider running away from light ... When you hover a ray of light ... spider slides to the side on their thin legs.
It seemed to me alone that he was moving in direction of the light source? scratch

We advise you to read:

Hand it for the smartphone ...