Arduino lumière demandeur d'

First of all, I’m from Switzerland so please excuse my english mistakes.

Here is one of my first little project I did with my Arduino Uno.

It’s is just a little light seeker. The servo turns towards the light.

Arduino light seeker

Step 1: The wiring

Here is the exact wiring I used.

The only difference is that I fixed the photoresistors on the servo (but I couldn’t do it with the program)

Also I used a 9V battery in the video, it was plugged in Vin and GND.

The resistors are 200 Ohm for the LED’s and 10 KOhm for the photoresistors.

 

Step 2: The code

This is my first code. I tried to translate the comments in english.

The Arduino calculate the difference between the left and right photoresistor and turns the servo if the difference is greater than 30.
When the servo is turning clockwise, the right LED lights up. When it turns counter clockwise, the left LED lights up

If you see any errors or weird thing, please tell me 🙂

#include
Servo servo; //define servo
//Variables
int photoD = 0;  //define pin 0 for right photoresistor
int photoG = 1;  //define pin 1 for left photoresistor
int ledD = 3;    //define pin 3 for right LED
int ledG = 5;    //define pin 5 for left LED
int incr = 5;     //value to add to the angle
int valS;          //angle
long temps;      //Time
long temps2;     //Time 2
long temps3;     //Time 3
long temps4;     //Time 4

//----------------------------------------------------------------------------

 

Major Components in Project
Arduino

For more detail: Arduino lumière demandeur d'


A Propos De L'Auteur

Ibrar Ayyub

Je suis expérimenté, rédacteur technique, titulaire d'une Maîtrise en informatique de BZU Multan, Pakistan à l'Université. Avec un arrière-plan couvrant diverses industries, notamment en matière de domotique et de l'ingénierie, j'ai perfectionné mes compétences dans la rédaction claire et concise du contenu. Compétent en tirant parti de l'infographie et des diagrammes, je m'efforce de simplifier des concepts complexes pour les lecteurs. Ma force réside dans une recherche approfondie et de présenter l'information de façon structurée et logique format.

Suivez-Nous:
LinkedinTwitter

Laisser un Commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *

fr_FRFrench
Faire défiler vers le Haut