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 - Arduino Tutorial
From the course: Learning Arduino: Interfacing with Analog Devices
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Using the joystick to control LEDs51s
-
(Locked)
Wiring up the joystick and LEDs32s
-
(Locked)
Coding for the joystick and LEDs6m 17s
-
(Locked)
Using an LDR sensor to control a motor21s
-
(Locked)
Wiring41s
-
(Locked)
Coding the LDR and sensor4m 9s
-
(Locked)
Using a joystick to control a motor49s
-
(Locked)
Wiring up the joystick and motor37s
-
(Locked)
Coding the joystick and motor5m 48s
-
(Locked)
-