From the course: Learning Arduino: Interfacing with Analog Devices

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Coding the LDR and sensor

Coding the LDR and sensor - Arduino Tutorial

From the course: Learning Arduino: Interfacing with Analog Devices

Start my 1-month free trial

Coding the LDR and sensor

- [Instructor] Alright so now to do the coding for this project, I have a starting file that you can open that's called Stepper_Motor_LDR where we are going to program in that the speed of the stepper motor will change with the light intensity. So here, in line number three again, we need to include the stepper motor library so we have in here, in line number five we have our Stepper function. I have the steps per valuation which is 32 and the way we did the wiring, remember that the motor sequence is one, three, two, four so it's going to be pin two, four, three, and five. In line number seven, we have the sensor pin where we connect the LDR to the Arduino board then I'm initializing two variables, one to save the values of the LDR which is sensor value and one to initialize the value for the motor speed that we are going to use in that function for that. And then in line number 10 we have a variable that's named direction and it has a value of 32, where we are going to use it in…

Contents